Debian Codegraph @

js/src/tests/test262/language/rest-parameters/with-new-target.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.1
5 description: >
6 with new target
7 includes: [compareArray.js]
8 ---*/
9 class Base {
10 constructor(...a) {
11 assert.sameValue(
12 arguments.length,
13 a.length,
14 "The value of `arguments.length` is `a.length`"
15 );
16 this.base = a;
17 var args = [];
18 for (var i = 0; i < arguments.length; ++i) {
19 args.push(arguments[i]);
20 }
21 assert.compareArray(args, a);
22 }
23 }
24 class Child extends Base {
25 constructor(...b) {
26 super(1, 2, 3);
27 assert.sameValue(
28 arguments.length,
29 b.length,
30 "The value of `arguments.length` is `b.length`"
31 );
32 this.child = b;
33 var args = [];
34 for (var i = 0; i < arguments.length; ++i) {
35 args.push(arguments[i]);
36 }
37 assert.compareArray(args, b);
38 }
39 }
40
41 var c = new Child(1, 2, 3);
42
43 assert.sameValue(c.child.length, 3, "The value of `c.child.length` is `3`");
44 assert.sameValue(c.base.length, 3, "The value of `c.base.length` is `3`");
45
46 assert.compareArray(
47 c.child,
48 [1, 2, 3]
49 );
50 assert.compareArray(
51 c.base,
52 [1, 2, 3]
53 );
54
55 reportCompare(0, 0);