Debian Codegraph @

js/src/tests/test262/language/statements/class/arguments/access.js

raw
1 // Copyright (C) 2014 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 es6id: 14.5
5 description: >
6 class arguments access
7 ---*/
8 var constructCounts = {
9 base: 0,
10 subclass: 0,
11 subclass2: 0
12 };
13
14 class Base {
15 constructor() {
16 constructCounts.base++;
17 assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`");
18 assert.sameValue(arguments[0], 1, "The value of `arguments[0]` is `1`");
19 assert.sameValue(arguments[1], 2, "The value of `arguments[1]` is `2`");
20 }
21 }
22
23 var b = new Base(1, 2);
24
25 class Subclass extends Base {
26 constructor() {
27 constructCounts.subclass++;
28 assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`");
29 assert.sameValue(arguments[0], 3, "The value of `arguments[0]` is `3`");
30 assert.sameValue(arguments[1], 4, "The value of `arguments[1]` is `4`");
31 super(1, 2);
32 }
33 }
34
35 var s = new Subclass(3, 4);
36 assert.sameValue(Subclass.length, 0, "The value of `Subclass.length` is `0`, because there are 0 formal parameters");
37
38 class Subclass2 extends Base {
39 constructor(x, y) {
40 constructCounts.subclass2++;
41 assert.sameValue(arguments.length, 2, "The value of `arguments.length` is `2`");
42 assert.sameValue(arguments[0], 3, "The value of `arguments[0]` is `3`");
43 assert.sameValue(arguments[1], 4, "The value of `arguments[1]` is `4`");
44 super(1, 2);
45 }
46 }
47
48 var s2 = new Subclass2(3, 4);
49 assert.sameValue(Subclass2.length, 2, "The value of `Subclass2.length` is `2`, because there are 2 formal parameters");
50
51
52 assert.sameValue(constructCounts.base, 3, "The value of `constructCounts.base` is `3`");
53 assert.sameValue(constructCounts.subclass, 1, "The value of `constructCounts.subclass` is `1`");
54 assert.sameValue(constructCounts.subclass2, 1, "The value of `constructCounts.subclass2` is `1`");
55
56 reportCompare(0, 0);