Debian Codegraph @

js/src/tests/test262/language/statements/class/params-dflt-meth-ref-arguments.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Referencing the arguments object from a default parameter (class expression method)
5 esid: sec-runtime-semantics-bindingclassdeclarationevaluation
6 es6id: 14.5.15
7 features: [default-parameters]
8 info: |
9 ClassDeclaration : class BindingIdentifier ClassTail
10
11 1. Let className be StringValue of BindingIdentifier.
12 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with
13 argument className.
14 [...]
15
16 14.5.14 Runtime Semantics: ClassDefinitionEvaluation
17
18 21. For each ClassElement m in order from methods
19 a. If IsStatic of m is false, then
20 i. Let status be the result of performing
21 PropertyDefinitionEvaluation for m with arguments proto and
22 false.
23 [...]
24
25 14.3.8 Runtime Semantics: DefineMethod
26
27 MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
28
29 [...]
30 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody,
31 scope, strict). If functionPrototype was passed as a parameter then pass its
32 value as the functionPrototype optional argument of FunctionCreate.
33 [...]
34
35 9.2.1 [[Call]] ( thisArgument, argumentsList)
36
37 [...]
38 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
39 [...]
40
41 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
42
43 1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
44 [...]
45
46 9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
47
48 [...]
49 23. Let iteratorRecord be Record {[[iterator]]:
50 CreateListIterator(argumentsList), [[done]]: false}.
51 24. If hasDuplicates is true, then
52 [...]
53 25. Else,
54 b. Let formalStatus be IteratorBindingInitialization for formals with
55 iteratorRecord and env as arguments.
56 [...]
57
58 14.1.19 Runtime Semantics: IteratorBindingInitialization
59
60 FormalsList : FormalsList , FormalParameter
61
62 1. Let status be the result of performing IteratorBindingInitialization for
63 FormalsList using iteratorRecord and environment as the arguments.
64 2. ReturnIfAbrupt(status).
65 3. Return the result of performing IteratorBindingInitialization for
66 FormalParameter using iteratorRecord and environment as the arguments.
67 ---*/
68
69 var callCount = 0;
70 class C {
71 method(x = arguments[2], y = arguments[3], z) {
72 assert.sameValue(x, 'third', 'first parameter');
73 assert.sameValue(y, 'fourth', 'second parameter');
74 assert.sameValue(z, 'third', 'third parameter');
75 callCount = callCount + 1;
76 }
77 }
78
79 C.prototype.method(undefined, undefined, 'third', 'fourth');
80
81 assert.sameValue(callCount, 1, 'method invoked exactly once');
82
83 reportCompare(0, 0);