Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-classes --harmony-sloppy | 5 // Flags: --harmony-classes --harmony-sloppy |
| 6 | 6 |
| 7 (function TestBasics() { | 7 (function TestBasics() { |
| 8 var C = class C {} | 8 var C = class C {} |
| 9 assertEquals(typeof C, 'function'); | 9 assertEquals(typeof C, 'function'); |
| 10 assertEquals(C.__proto__, Function.prototype); | 10 assertEquals(C.__proto__, Function.prototype); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 | 868 |
| 869 class C3 extends Object { | 869 class C3 extends Object { |
| 870 constructor() { | 870 constructor() { |
| 871 ; 'use strict';;;;; | 871 ; 'use strict';;;;; |
| 872 // This is a comment. | 872 // This is a comment. |
| 873 super(); | 873 super(); |
| 874 } | 874 } |
| 875 }; | 875 }; |
| 876 new C3(); | 876 new C3(); |
| 877 }()); | 877 }()); |
| 878 | |
| 879 | |
| 880 function testClassRestrictedProperties(C) { | |
| 881 assertEquals(false, C.hasOwnProperty("arguments")); | |
| 882 assertEquals(null, C.arguments); | |
| 883 | |
| 884 assertEquals(false, C.hasOwnProperty("caller")); | |
| 885 assertEquals(null, C.caller); | |
| 886 | |
| 887 assertEquals(false, (new C).method.hasOwnProperty("arguments")); | |
| 888 assertEquals(null, (new C).method.arguments); | |
| 889 | |
| 890 assertEquals(false, (new C).method.hasOwnProperty("caller")); | |
| 891 assertEquals(null, (new C).method.caller); | |
| 892 } | |
| 893 | |
| 894 | |
| 895 (function testRestrictedPropertiesStrict() { | |
| 896 "use strict"; | |
| 897 class ClassWithDefaultConstructor { | |
| 898 method() {} | |
| 899 } | |
| 900 class Class { | |
| 901 constructor() {} | |
| 902 method() {} | |
| 903 } | |
|
arv (Not doing code reviews)
2015/03/25 13:36:47
Maybe have a derived class too?
| |
| 904 | |
| 905 testClassRestrictedProperties(ClassWithDefaultConstructor); | |
| 906 testClassRestrictedProperties(Class); | |
| 907 testClassRestrictedProperties(class { method() {} }); | |
| 908 testClassRestrictedProperties(class { constructor() {} method() {} }); | |
| 909 })(); | |
| 910 | |
| 911 | |
| 912 (function testRestrictedPropertiesSloppy() { | |
| 913 class ClassWithDefaultConstructor { | |
| 914 method() {} | |
| 915 } | |
| 916 class Class { | |
| 917 constructor() {} | |
| 918 method() {} | |
| 919 } | |
| 920 | |
| 921 testClassRestrictedProperties(ClassWithDefaultConstructor); | |
| 922 testClassRestrictedProperties(Class); | |
| 923 testClassRestrictedProperties(class { method() {} }); | |
| 924 testClassRestrictedProperties(class { constructor() {} method() {} }); | |
| 925 })(); | |
| OLD | NEW |