Reviewers: Dmitry Lomov (chromium),
Message:
PTAL
Description:
Classes: Add more tests for prototype edge cases
BUG=3655
LOG=Y
Please review this at https://codereview.chromium.org/687453004/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+51, -0 lines):
M test/mjsunit/harmony/classes.js
Index: test/mjsunit/harmony/classes.js
diff --git a/test/mjsunit/harmony/classes.js
b/test/mjsunit/harmony/classes.js
index
3a22fd9b5427dcf74873f541744fcd65c42a7978..c44c2cdcb9a05ab229caec8949f6f71f4685594f
100644
--- a/test/mjsunit/harmony/classes.js
+++ b/test/mjsunit/harmony/classes.js
@@ -174,6 +174,7 @@ function assertMethodDescriptor(object, name) {
assertEquals('function', typeof descr.value);
}
+
function assertGetterDescriptor(object, name) {
var descr = Object.getOwnPropertyDescriptor(object, name);
assertTrue(descr.configurable);
@@ -387,6 +388,56 @@ function assertAccessorDescriptor(object, name) {
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.