Debian Codegraph @

js/src/tests/test262/language/statements/class/definition/this-check-ordering.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 this check ordering
7 ---*/
8 var baseCalled = 0;
9 class Base {
10 constructor() { baseCalled++ }
11 }
12
13 var fCalled = 0;
14 function f() { fCalled++; return 3; }
15
16 class Subclass1 extends Base {
17 constructor() {
18 baseCalled = 0;
19 super();
20 assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
21 var obj = this;
22
23 var exn = null;
24 baseCalled = 0;
25 fCalled = 0;
26 try {
27 super(f());
28 } catch (e) { exn = e; }
29 assert.sameValue(
30 exn instanceof ReferenceError,
31 true,
32 "The result of `exn instanceof ReferenceError` is `true`"
33 );
34 assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`");
35 assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
36 assert.sameValue(this, obj, "`this` is `obj`");
37
38 exn = null;
39 baseCalled = 0;
40 fCalled = 0;
41 try {
42 super(super(), f());
43 } catch (e) { exn = e; }
44 assert.sameValue(
45 exn instanceof ReferenceError,
46 true,
47 "The result of `exn instanceof ReferenceError` is `true`"
48 );
49 assert.sameValue(fCalled, 0, "The value of `fCalled` is `0`");
50 assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
51 assert.sameValue(this, obj, "`this` is `obj`");
52
53 exn = null;
54 baseCalled = 0;
55 fCalled = 0;
56 try {
57 super(f(), super());
58 } catch (e) { exn = e; }
59 assert.sameValue(
60 exn instanceof ReferenceError,
61 true,
62 "The result of `exn instanceof ReferenceError` is `true`"
63 );
64 assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`");
65 assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
66 assert.sameValue(this, obj, "`this` is `obj`");
67 }
68 }
69
70 new Subclass1();
71
72 reportCompare(0, 0);