Debian Codegraph @

js/src/tests/test262/language/arguments-object/meth-args-trailing-comma-spread-operator.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/arguments/args-trailing-comma-spread-operator.case
3 // - src/arguments/default/meth.template
4 /*---
5 description: A trailing comma should not increase the arguments.length, using spread args (method)
6 esid: sec-arguments-exotic-objects
7 flags: [generated]
8 info: |
9 9.4.4 Arguments Exotic Objects
10
11 Most ECMAScript functions make an arguments object available to their code. Depending upon the
12 characteristics of the function definition, its arguments object is either an ordinary object
13 or an arguments exotic object.
14
15 Trailing comma in the arguments list
16
17 Left-Hand-Side Expressions
18
19 Arguments :
20 ( )
21 ( ArgumentList )
22 ( ArgumentList , )
23
24 ArgumentList :
25 AssignmentExpression
26 ... AssignmentExpression
27 ArgumentList , AssignmentExpression
28 ArgumentList , ... AssignmentExpression
29 ---*/
30 var arr = [2, 3];
31
32
33
34 var callCount = 0;
35 var obj = {
36 method() {
37 assert.sameValue(arguments.length, 4);
38 assert.sameValue(arguments[0], 42);
39 assert.sameValue(arguments[1], 1);
40 assert.sameValue(arguments[2], 2);
41 assert.sameValue(arguments[3], 3);
42 callCount = callCount + 1;
43 }
44 };
45
46 obj.method(42, ...[1], ...arr,);
47
48 // Stores a reference `ref` for case evaluation
49 var ref = obj.method;
50
51 assert.sameValue(callCount, 1, 'method invoked exactly once');
52
53 reportCompare(0, 0);