Debian Codegraph @

js/src/tests/test262/language/statements/class/static-init-arguments-methods.js

raw
1 // Copyright (C) 2021 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-class-definitions-static-semantics-early-errors
5 description: The identifier `arguments` is not restricted within method forms
6 info: |
7 ClassStaticBlockBody : ClassStaticBlockStatementList
8
9 - It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList
10 is true.
11 includes: [compareArray.js]
12 features: [class-static-block]
13 ---*/
14
15 var instance;
16 var method, methodParam;
17 var getter;
18 var setter, setterParam;
19 var genMethod, genMethodParam;
20 var asyncMethod, asyncMethodParam;
21
22 class C {
23 static {
24 instance = new class {
25 method({test262 = methodParam = arguments}) {
26 method = arguments;
27 }
28 get accessor() {
29 getter = arguments;
30 }
31 set accessor({test262 = setterParam = arguments}) {
32 setter = arguments;
33 }
34 *gen({test262 = genMethodParam = arguments}) {
35 genMethod = arguments;
36 }
37 async async({test262 = asyncMethodParam = arguments}) {
38 asyncMethod = arguments;
39 }
40 }();
41 }
42 }
43
44 instance.method('method');
45 instance.accessor;
46 instance.accessor = 'setter';
47 instance.gen('generator method').next();
48 instance.async('async method');
49
50 assert.compareArray(['method'], method, 'body');
51 assert.compareArray(['method'], methodParam, 'parameter');
52 assert.compareArray([], getter, 'body');
53 assert.compareArray(['setter'], setter, 'body');
54 assert.compareArray(['setter'], setterParam, 'parameter');
55 assert.compareArray(['generator method'], genMethod, 'body');
56 assert.compareArray(['generator method'], genMethodParam, 'parameter');
57 assert.compareArray(['async method'], asyncMethod, 'body');
58 assert.compareArray(['async method'], asyncMethodParam, 'parameter');
59
60 reportCompare(0, 0);