Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: test/mjsunit/harmony/classes.js

Issue 687453004: Classes: Add more tests for prototype edge cases (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698