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
This commit is contained in:
parent
81aaeb476d
commit
013a29a2bc
@ -175,6 +175,7 @@ function assertMethodDescriptor(object, name) {
|
||||
assertFalse('prototype' in descr.value);
|
||||
}
|
||||
|
||||
|
||||
function assertGetterDescriptor(object, name) {
|
||||
var descr = Object.getOwnPropertyDescriptor(object, name);
|
||||
assertTrue(descr.configurable);
|
||||
@ -388,6 +389,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user