Debian Codegraph @

js/src/tests/test262/language/statements/class/definition/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 constructor
7 ---*/
8 var count = 0;
9 class C {
10 constructor() {
11 assert.sameValue(
12 Object.getPrototypeOf(this),
13 C.prototype,
14 "`Object.getPrototypeOf(this)` returns `C.prototype`"
15 );
16 count++;
17 }
18 }
19 assert.sameValue(
20 C,
21 C.prototype.constructor,
22 "The value of `C` is `C.prototype.constructor`"
23 );
24 var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');
25 assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`");
26 assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`");
27 assert.sameValue(desc.writable, true, "The value of `descr.writable` is `true`, after executing `var desc = Object.getOwnPropertyDescriptor(C.prototype, 'constructor');`");
28
29 var c = new C();
30 assert.sameValue(count, 1, "The value of `count` is `1`");
31 assert.sameValue(
32 Object.getPrototypeOf(c),
33 C.prototype,
34 "`Object.getPrototypeOf(c)` returns `C.prototype`"
35 );
36
37 reportCompare(0, 0);