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

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

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Should be ReferenceError Created 5 years, 9 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 | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strong/classes.js
diff --git a/test/mjsunit/strong/classes.js b/test/mjsunit/strong/classes.js
index 3c7caf5f84e4a5d31ac3519d975816a4be05ae8b..d5c4560844e688b2fa335f3b63b62ab9b4dbd9ca 100644
--- a/test/mjsunit/strong/classes.js
+++ b/test/mjsunit/strong/classes.js
@@ -3,15 +3,44 @@
// found in the LICENSE file.
// Flags: --strong-mode
+// Flags: --harmony-classes --harmony-arrow-functions
'use strong';
class C {}
+function assertTypeError(script) { assertThrows(script, TypeError) }
+function assertSyntaxError(script) { assertThrows(script, SyntaxError) }
+function assertReferenceError(script) { assertThrows(script, ReferenceError) }
+
(function ImmutableClassBindings() {
class D {}
- assertThrows(function(){ eval("C = 0") }, TypeError);
- assertThrows(function(){ eval("D = 0") }, TypeError);
+ assertTypeError(function(){ eval("C = 0") });
+ assertTypeError(function(){ eval("D = 0") });
assertEquals('function', typeof C);
assertEquals('function', typeof D);
})();
+
+function constructor(body) {
+ return "'use strong'; " +
+ "(class extends Object { constructor() { " + body + " } })";
+}
+
+(function NoMissingSuper() {
+ assertReferenceError(constructor(""));
+ assertReferenceError(constructor("1"));
+})();
+
+(function NoNestedSuper() {
+ assertSyntaxError(constructor("(super())"));
+ assertSyntaxError(constructor("(() => super())(); } })"));
+ assertSyntaxError(constructor("{ super();"));
+ assertSyntaxError(constructor("if (1) super();"));
+})();
+
+(function NoDuplicateSuper() {
+ assertSyntaxError(constructor("super(), super();"));
+ assertSyntaxError(constructor("super(); super();"));
+ assertSyntaxError(constructor("super(); (super());"));
+ assertSyntaxError(constructor("super(); { super() }"));
+})();
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698