Index: test/mjsunit/harmony/classes.js |
diff --git a/test/mjsunit/harmony/classes.js b/test/mjsunit/harmony/classes.js |
index 1b19a13193a45e7205ba8e1070015184a8240dc2..8388a97bfb32d022658e21a79760d392fb4030ff 100644 |
--- a/test/mjsunit/harmony/classes.js |
+++ b/test/mjsunit/harmony/classes.js |
@@ -875,3 +875,65 @@ function assertAccessorDescriptor(object, name) { |
}; |
new C3(); |
}()); |
+ |
+ |
+function testClassRestrictedProperties(C) { |
+ assertEquals(false, C.hasOwnProperty("arguments")); |
+ assertThrows(function() { return C.arguments; }, TypeError); |
+ |
+ assertEquals(false, C.hasOwnProperty("caller")); |
+ assertThrows(function() { return C.caller; }, TypeError); |
+ |
+ assertEquals(false, (new C).method.hasOwnProperty("arguments")); |
+ assertThrows(function() { return (new C).method.arguments; }, TypeError); |
+ |
+ assertEquals(false, (new C).method.hasOwnProperty("caller")); |
+ assertThrows(function() { return (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(); } }); |
+})(); |