Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // Flags: --harmony-classes --allow-natives-syntax | |
| 6 'use strict'; | |
| 7 | |
| 8 (function TestMaps() { | |
| 9 class Base {} | |
| 10 class Derived extends Base {} | |
| 11 | |
| 12 let d1 = new Derived(); | |
| 13 let d2 = new Derived(); | |
| 14 | |
| 15 assertTrue(%HaveSameMap(d1, d2)); | |
| 16 }()); | |
| 17 | |
| 18 | |
| 19 (function TestProtoModificationArray() { | |
| 20 let called = 0; | |
| 21 function F() { | |
| 22 called++; | |
| 23 assertFalse(Array.isArray(this)); | |
| 24 } | |
| 25 class Derived extends Array {} | |
| 26 assertSame(Derived.__proto__, Array); | |
| 27 | |
| 28 let d1 = new Derived(); | |
| 29 assertTrue(Array.isArray(d1)); | |
| 30 | |
| 31 Derived.__proto__ = F; | |
| 32 called = 0; | |
| 33 let d2 = new Derived(); | |
| 34 assertSame(1, called); | |
| 35 assertFalse(Array.isArray(d2)); | |
| 36 | |
| 37 assertFalse(%HaveSameMap(d1, d2)); | |
| 38 }()); | |
| 39 | |
| 40 | |
| 41 (function TestProtoModification() { | |
| 42 let called = 0; | |
| 43 function F() { | |
| 44 called++; | |
| 45 let exn = null; | |
| 46 try { | |
| 47 this.byteLength; | |
| 48 } | |
| 
 
arv (Not doing code reviews)
2015/04/13 15:59:39
nit: 
} catch (e) {
 
Dmitry Lomov (no reviews)
2015/04/14 09:34:27
Done.
 
 | |
| 49 catch (e) { | |
| 50 exn = e; | |
| 51 } | |
| 52 assertTrue(exn instanceof TypeError); | |
| 53 } | |
| 54 class Derived extends Uint8Array { | |
| 55 constructor() { super(10); } | |
| 56 } | |
| 57 assertSame(Derived.__proto__, Uint8Array); | |
| 58 | |
| 59 let d1 = new Derived(); | |
| 60 assertSame(10, d1.byteLength); | |
| 61 | |
| 62 Derived.__proto__ = F; | |
| 63 called = 0; | |
| 64 let d2 = new Derived(); | |
| 65 assertSame(1, called); | |
| 66 assertThrows(function() { d2.byteLength; }, TypeError); | |
| 67 | |
| 68 assertFalse(%HaveSameMap(d1, d2)); | |
| 69 }()); | |
| OLD | NEW |