summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/static-init-arguments-methods.js
blob: bb4f12c008da98e6366a8ba8e0e163070b081df5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-class-definitions-static-semantics-early-errors
description: The identifier `arguments` is not restricted within method forms
info: |
  ClassStaticBlockBody : ClassStaticBlockStatementList

  - It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList
    is true.
includes: [compareArray.js]
features: [class-static-block]
---*/

var instance;
var method, methodParam;
var getter;
var setter, setterParam;
var genMethod, genMethodParam;
var asyncMethod, asyncMethodParam;

class C {
  static {
    instance = new class {
      method({test262 = methodParam = arguments}) {
        method = arguments;
      }
      get accessor() {
        getter = arguments;
      }
      set accessor({test262 = setterParam = arguments}) {
        setter = arguments;
      }
      *gen({test262 = genMethodParam = arguments}) {
        genMethod = arguments;
      }
      async async({test262 = asyncMethodParam = arguments}) {
        asyncMethod = arguments;
      }
    }();
  }
}

instance.method('method');
instance.accessor;
instance.accessor = 'setter';
instance.gen('generator method').next();
instance.async('async method');

assert.compareArray(['method'], method, 'body');
assert.compareArray(['method'], methodParam, 'parameter');
assert.compareArray([], getter, 'body');
assert.compareArray(['setter'], setter, 'body');
assert.compareArray(['setter'], setterParam, 'parameter');
assert.compareArray(['generator method'], genMethod, 'body');
assert.compareArray(['generator method'], genMethodParam, 'parameter');
assert.compareArray(['async method'], asyncMethod, 'body');
assert.compareArray(['async method'], asyncMethodParam, 'parameter');

reportCompare(0, 0);