Debian Codegraph @

js/src/tests/test262/language/statements/class/arguments/default-constructor.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 default constructor arguments
7 ---*/
8 var args, that;
9 class Base {
10 constructor() {
11 that = this;
12 args = arguments;
13 }
14 }
15 class Derived extends Base {}
16
17 new Derived;
18 assert.sameValue(args.length, 0, "The value of `args.length` is `0`");
19
20 new Derived(0, 1, 2);
21 assert.sameValue(args.length, 3, "The value of `args.length` is `3`");
22 assert.sameValue(
23 that instanceof Derived,
24 true,
25 "The result of `that instanceof Derived` is `true`"
26 );
27
28 var arr = new Array(100);
29 var obj = {};
30 assert.throws(TypeError, function() {Derived.apply(obj, arr);});
31
32 reportCompare(0, 0);