Index: test/mjsunit/harmony/classes-maps.js |
diff --git a/test/mjsunit/harmony/classes-maps.js b/test/mjsunit/harmony/classes-maps.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..20234ce5e002e1ec5f907948c77461121a24c434 |
--- /dev/null |
+++ b/test/mjsunit/harmony/classes-maps.js |
@@ -0,0 +1,62 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+// |
+// Flags: --harmony-classes --allow-natives-syntax |
+'use strict'; |
+ |
+(function TestMaps() { |
+ class Base {} |
+ class Derived extends Base {} |
+ |
+ let d1 = new Derived(); |
+ let d2 = new Derived(); |
+ |
+ assertTrue(%HaveSameMap(d1, d2)); |
+}()); |
+ |
+ |
+(function TestProtoModificationArray() { |
+ let called = 0; |
+ function F() { |
+ called++; |
+ assertFalse(Array.isArray(this)); |
+ } |
+ class Derived extends Array {} |
+ assertSame(Derived.__proto__, Array); |
+ |
+ let d1 = new Derived(); |
+ assertTrue(Array.isArray(d1)); |
+ |
+ Derived.__proto__ = F; |
+ called = 0; |
+ let d2 = new Derived(); |
+ assertSame(1, called); |
+ assertFalse(Array.isArray(d2)); |
+ |
+ assertFalse(%HaveSameMap(d1, d2)); |
+}()); |
+ |
+ |
+(function TestProtoModification() { |
+ let called = 0; |
+ function F() { |
+ called++; |
+ assertThrows(function() { this.byteLength; }, TypeError); |
arv (Not doing code reviews)
2015/04/02 13:02:32
wrong `this` so you get a TypeError because this =
Dmitry Lomov (no reviews)
2015/04/13 09:50:40
Oh, embarassing!
Done.
|
+ } |
+ class Derived extends Uint8Array { |
+ constructor() { super(10); } |
+ } |
+ assertSame(Derived.__proto__, Uint8Array); |
+ |
+ let d1 = new Derived(); |
+ assertSame(10, d1.byteLength); |
+ |
+ Derived.__proto__ = F; |
+ called = 0; |
+ let d2 = new Derived(); |
+ assertSame(1, called); |
+ assertThrows(function() { d2.byteLength; }, TypeError); |
+ |
+ assertFalse(%HaveSameMap(d1, d2)); |
+}()); |