Commit 013a29a2 authored by arv@chromium.org's avatar arv@chromium.org

Classes: Add more tests for prototype edge cases

BUG=3655
LOG=Y
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/687453004

Cr-Commit-Position: refs/heads/master@{#24943}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24943 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 81aaeb47
...@@ -175,6 +175,7 @@ function assertMethodDescriptor(object, name) { ...@@ -175,6 +175,7 @@ function assertMethodDescriptor(object, name) {
assertFalse('prototype' in descr.value); assertFalse('prototype' in descr.value);
} }
function assertGetterDescriptor(object, name) { function assertGetterDescriptor(object, name) {
var descr = Object.getOwnPropertyDescriptor(object, name); var descr = Object.getOwnPropertyDescriptor(object, name);
assertTrue(descr.configurable); assertTrue(descr.configurable);
...@@ -388,6 +389,56 @@ function assertAccessorDescriptor(object, name) { ...@@ -388,6 +389,56 @@ function assertAccessorDescriptor(object, name) {
assertEquals(2, C.staticM()); 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 /* TODO(arv): Implement
(function TestNameBindingInConstructor() { (function TestNameBindingInConstructor() {
class C { class C {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment