OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Flags: --experimental-classes --harmony-classes | 5 // Flags: --experimental-classes --harmony-classes |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 (function TestArgumentsAccess() { | 8 (function TestArgumentsAccess() { |
9 class Base { | 9 class Base { |
10 constructor() { | 10 constructor() { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 if (x < 0) return; | 83 if (x < 0) return; |
84 | 84 |
85 let called = false; | 85 let called = false; |
86 function tmp() { called = true; return 3; } | 86 function tmp() { called = true; return 3; } |
87 var exn = null; | 87 var exn = null; |
88 try { | 88 try { |
89 super(tmp(),4); | 89 super(tmp(),4); |
90 } catch (e) { exn = e; } | 90 } catch (e) { exn = e; } |
91 assertTrue(exn instanceof ReferenceError); | 91 assertTrue(exn instanceof ReferenceError); |
92 // TODO(dslomov): should be 'true'. | 92 assertTrue(called); |
93 assertFalse(called); | |
94 } | 93 } |
95 } | 94 } |
96 | 95 |
97 var s2 = new Subclass2(1); | 96 var s2 = new Subclass2(1); |
98 assertSame(3, s2.prp); | 97 assertSame(3, s2.prp); |
99 | 98 |
100 var s3 = new Subclass2(-1); | 99 var s3 = new Subclass2(-1); |
101 assertSame(3, s3.prp); | 100 assertSame(3, s3.prp); |
102 | 101 |
103 assertThrows(function() { Subclass.call(new Object(), 1, 2); }, TypeError); | 102 assertThrows(function() { Subclass.call(new Object(), 1, 2); }, TypeError); |
104 assertThrows(function() { Base.call(new Object(), 1, 2); }, TypeError); | 103 assertThrows(function() { Base.call(new Object(), 1, 2); }, TypeError); |
105 | 104 |
106 class BadSubclass extends Base { | 105 class BadSubclass extends Base { |
107 constructor() {} | 106 constructor() {} |
108 } | 107 } |
109 | 108 |
110 assertThrows(function() { new BadSubclass(); }, ReferenceError); | 109 assertThrows(function() { new BadSubclass(); }, ReferenceError); |
111 }()); | 110 }()); |
112 | 111 |
| 112 (function TestThisCheckOrdering() { |
| 113 let baseCalled = 0; |
| 114 class Base { |
| 115 constructor() { baseCalled++ } |
| 116 } |
| 117 |
| 118 let fCalled = 0; |
| 119 function f() { fCalled++; return 3; } |
| 120 |
| 121 class Subclass1 extends Base { |
| 122 constructor() { |
| 123 baseCalled = 0; |
| 124 super(); |
| 125 assertEquals(1, baseCalled); |
| 126 let obj = this; |
| 127 |
| 128 let exn = null; |
| 129 baseCalled = 0; |
| 130 fCalled = 0; |
| 131 try { |
| 132 super(f()); |
| 133 } catch (e) { exn = e; } |
| 134 assertTrue(exn instanceof ReferenceError); |
| 135 assertEquals(1, fCalled); |
| 136 assertEquals(1, baseCalled); |
| 137 assertSame(obj, this); |
| 138 |
| 139 exn = null; |
| 140 baseCalled = 0; |
| 141 fCalled = 0; |
| 142 try { |
| 143 super(super(), f()); |
| 144 } catch (e) { exn = e; } |
| 145 assertTrue(exn instanceof ReferenceError); |
| 146 assertEquals(0, fCalled); |
| 147 assertEquals(1, baseCalled); |
| 148 assertSame(obj, this); |
| 149 |
| 150 exn = null; |
| 151 baseCalled = 0; |
| 152 fCalled = 0; |
| 153 try { |
| 154 super(f(), super()); |
| 155 } catch (e) { exn = e; } |
| 156 assertTrue(exn instanceof ReferenceError); |
| 157 assertEquals(1, fCalled); |
| 158 assertEquals(1, baseCalled); |
| 159 assertSame(obj, this); |
| 160 } |
| 161 } |
| 162 |
| 163 new Subclass1(); |
| 164 }()); |
| 165 |
| 166 |
113 (function TestPrototypeWiring() { | 167 (function TestPrototypeWiring() { |
114 class Base { | 168 class Base { |
115 constructor(x) { | 169 constructor(x) { |
116 this.foobar = x; | 170 this.foobar = x; |
117 } | 171 } |
118 } | 172 } |
119 | 173 |
120 class Subclass extends Base { | 174 class Subclass extends Base { |
121 constructor(x) { | 175 constructor(x) { |
122 super(x); | 176 super(x); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 var eua = new ExtendedUint8Array(10); | 330 var eua = new ExtendedUint8Array(10); |
277 assertEquals(10, eua.length); | 331 assertEquals(10, eua.length); |
278 assertEquals(10, eua.byteLength); | 332 assertEquals(10, eua.byteLength); |
279 eua[0] = 0xFF; | 333 eua[0] = 0xFF; |
280 eua[1] = 0xFFA; | 334 eua[1] = 0xFFA; |
281 assertEquals(0xFF, eua[0]); | 335 assertEquals(0xFF, eua[0]); |
282 assertEquals(0xFA, eua[1]); | 336 assertEquals(0xFA, eua[1]); |
283 assertSame(ExtendedUint8Array.prototype, eua.__proto__); | 337 assertSame(ExtendedUint8Array.prototype, eua.__proto__); |
284 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua)); | 338 assertEquals("[object Uint8Array]", Object.prototype.toString.call(eua)); |
285 }()); | 339 }()); |
OLD | NEW |