Revision: 24943
Author:   [email protected]
Date:     Tue Oct 28 14:12:18 2014 UTC
Log:      Classes: Add more tests for prototype edge cases

BUG=3655
LOG=Y
[email protected]

Review URL: https://codereview.chromium.org/687453004
https://code.google.com/p/v8/source/detail?r=24943

Modified:
 /branches/bleeding_edge/test/mjsunit/harmony/classes.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/classes.js Tue Oct 28 13:39:41 2014 UTC +++ /branches/bleeding_edge/test/mjsunit/harmony/classes.js Tue Oct 28 14:12:18 2014 UTC
@@ -174,6 +174,7 @@
   assertEquals('function', typeof descr.value);
   assertFalse('prototype' in descr.value);
 }
+

 function assertGetterDescriptor(object, name) {
   var descr = Object.getOwnPropertyDescriptor(object, name);
@@ -388,6 +389,56 @@
   assertEquals(2, C.staticM());
 })();

+
+(function TestConstructableButNoPrototype() {
+  var Base = function() {}.bind();
+  assertThrows(function() {
+    class C extends Base {}
+  }, TypeError);
+})();
+
+
+(function TestPrototypeGetter() {
+  var calls = 0;
+  var Base = function() {}.bind();
+  Object.defineProperty(Base, 'prototype', {
+    get: function() {
+      calls++;
+      return null;
+    },
+    configurable: true
+  });
+  class C extends Base {}
+  assertEquals(1, calls);
+
+  calls = 0;
+  Object.defineProperty(Base, 'prototype', {
+    get: function() {
+      calls++;
+      return 42;
+    },
+    configurable: true
+  });
+  assertThrows(function() {
+    class C extends Base {}
+  }, TypeError);
+  assertEquals(1, calls);
+})();
+
+
+(function TestPrototypeSetter() {
+  var Base = function() {}.bind();
+  Object.defineProperty(Base, 'prototype', {
+    set: function() {
+      assertUnreachable();
+    }
+  });
+  assertThrows(function() {
+    class C extends Base {}
+  }, TypeError);
+})();
+
+
 /* TODO(arv): Implement
 (function TestNameBindingInConstructor() {
   class C {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to