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() { |
arv (Not doing code reviews)
2015/04/07 16:18:39
Classes are always strict so I'm not sure this add
caitp (gmail)
2015/04/07 16:29:57
you could say it verifies the logic of the map pic
|
+ 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(); } }); |
+})(); |