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

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

Issue 1027283004: [es6] do not add caller/arguments to ES6 function definitions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 8 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/mjsunit/harmony/arrow-functions.js ('k') | test/mjsunit/harmony/computed-property-names-classes.js » ('j') | 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 1b19a13193a45e7205ba8e1070015184a8240dc2..b74b2886a551c7e566da14ae0ab48bd5e89de68b 100644
--- a/test/mjsunit/harmony/classes.js
+++ b/test/mjsunit/harmony/classes.js
@@ -875,3 +875,69 @@ function assertAccessorDescriptor(object, name) {
};
new C3();
}());
+
+
+function testClassRestrictedProperties(C) {
+ assertEquals(false, C.hasOwnProperty("arguments"));
+ assertThrows(function() { return C.arguments; }, TypeError);
+ assertThrows(function() { C.arguments = {}; }, TypeError);
+
+ assertEquals(false, C.hasOwnProperty("caller"));
+ assertThrows(function() { return C.caller; }, TypeError);
+ assertThrows(function() { C.caller = {}; }, TypeError);
+
+ assertEquals(false, (new C).method.hasOwnProperty("arguments"));
+ assertThrows(function() { return new C().method.arguments; }, TypeError);
+ assertThrows(function() { new C().method.arguments = {}; }, TypeError);
+
+ assertEquals(false, (new C).method.hasOwnProperty("caller"));
+ assertThrows(function() { return new C().method.caller; }, TypeError);
+ assertThrows(function() { new C().method.caller = {}; }, TypeError);
+}
+
+
+(function testRestrictedPropertiesStrict() {
+ "use strict";
+ class ClassWithDefaultConstructor {
+ method() {}
+ }
+ class Class {
+ constructor() {}
+ method() {}
+ }
+ class DerivedClassWithDefaultConstructor extends Class {}
+ class DerivedClass extends Class { constructor() { super(); } }
+
+ testClassRestrictedProperties(ClassWithDefaultConstructor);
+ testClassRestrictedProperties(Class);
+ testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
+ testClassRestrictedProperties(DerivedClass);
+ testClassRestrictedProperties(class { method() {} });
+ testClassRestrictedProperties(class { constructor() {} method() {} });
+ testClassRestrictedProperties(class extends Class { });
+ testClassRestrictedProperties(
+ class extends Class { constructor() { super(); } });
+})();
+
+
+(function testRestrictedPropertiesSloppy() {
+ class ClassWithDefaultConstructor {
+ method() {}
+ }
+ class Class {
+ constructor() {}
+ method() {}
+ }
+ class DerivedClassWithDefaultConstructor extends Class {}
+ class DerivedClass extends Class { constructor() { super(); } }
+
+ testClassRestrictedProperties(ClassWithDefaultConstructor);
+ testClassRestrictedProperties(Class);
+ testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
+ testClassRestrictedProperties(DerivedClass);
+ testClassRestrictedProperties(class { method() {} });
+ testClassRestrictedProperties(class { constructor() {} method() {} });
+ testClassRestrictedProperties(class extends Class { });
+ testClassRestrictedProperties(
+ class extends Class { constructor() { super(); } });
+})();
« no previous file with comments | « test/mjsunit/harmony/arrow-functions.js ('k') | test/mjsunit/harmony/computed-property-names-classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698