Debian Codegraph @

js/src/tests/test262/language/expressions/function/dflt-params-trailing-comma.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/function-forms/dflt-params-trailing-comma.case
3 // - src/function-forms/default/func-expr.template
4 /*---
5 description: A trailing comma should not increase the respective length, using default parameters (function expression)
6 esid: sec-function-definitions-runtime-semantics-evaluation
7 flags: [generated]
8 info: |
9 FunctionExpression : function ( FormalParameters ) { FunctionBody }
10
11 [...]
12 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody,
13 scope, strict).
14 [...]
15
16 9.2.1 [[Call]] ( thisArgument, argumentsList)
17
18 [...]
19 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
20 [...]
21
22 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
23
24 1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
25 [...]
26
27 9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
28
29 [...]
30 23. Let iteratorRecord be Record {[[iterator]]:
31 CreateListIterator(argumentsList), [[done]]: false}.
32 24. If hasDuplicates is true, then
33 [...]
34 25. Else,
35 b. Let formalStatus be IteratorBindingInitialization for formals with
36 iteratorRecord and env as arguments.
37 [...]
38
39 Trailing comma in the parameters list
40
41 14.1 Function Definitions
42
43 FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
44 ---*/
45
46 var callCount = 0;
47 // Stores a reference `ref` for case evaluation
48 var ref;
49 ref = function(a, b = 39,) {
50 assert.sameValue(a, 42);
51 assert.sameValue(b, 39);
52 callCount = callCount + 1;
53 };
54
55 ref(42, undefined, 1);
56
57 assert.sameValue(callCount, 1, 'function invoked exactly once');
58
59 assert.sameValue(ref.length, 1, 'length is properly set');
60
61 reportCompare(0, 0);