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

Side by Side 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: Rename variable, add some comments 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 unified diff | Download patch
OLDNEW
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
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 assertThrows(function() { return C.arguments; }, TypeError);
883
884 assertEquals(false, C.hasOwnProperty("caller"));
885 assertThrows(function() { return C.caller; }, TypeError);
886
887 assertEquals(false, (new C).method.hasOwnProperty("arguments"));
888 assertThrows(function() { return (new C).method.arguments; }, TypeError);
889
890 assertEquals(false, (new C).method.hasOwnProperty("caller"));
891 assertThrows(function() { return (new C).method.caller; }, TypeError);
892 }
893
894
895 (function testRestrictedPropertiesStrict() {
896 "use strict";
897 class ClassWithDefaultConstructor {
898 method() {}
899 }
900 class Class {
901 constructor() {}
902 method() {}
903 }
904 class DerivedClassWithDefaultConstructor extends Class {}
905 class DerivedClass extends Class { constructor() { super(); } }
906
907 testClassRestrictedProperties(ClassWithDefaultConstructor);
908 testClassRestrictedProperties(Class);
909 testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
910 testClassRestrictedProperties(DerivedClass);
911 testClassRestrictedProperties(class { method() {} });
912 testClassRestrictedProperties(class { constructor() {} method() {} });
913 testClassRestrictedProperties(class extends Class { });
914 testClassRestrictedProperties(
915 class extends Class { constructor() { super(); } });
916 })();
917
918
919 (function testRestrictedPropertiesSloppy() {
920 class ClassWithDefaultConstructor {
921 method() {}
922 }
923 class Class {
924 constructor() {}
925 method() {}
926 }
927 class DerivedClassWithDefaultConstructor extends Class {}
928 class DerivedClass extends Class { constructor() { super(); } }
929
930 testClassRestrictedProperties(ClassWithDefaultConstructor);
931 testClassRestrictedProperties(Class);
932 testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
933 testClassRestrictedProperties(DerivedClass);
934 testClassRestrictedProperties(class { method() {} });
935 testClassRestrictedProperties(class { constructor() {} method() {} });
936 testClassRestrictedProperties(class extends Class { });
937 testClassRestrictedProperties(
938 class extends Class { constructor() { super(); } });
939 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698