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

Side by Side Diff: test/mjsunit/es6/classes.js

Issue 1418623007: [runtime] Fix ES6 9.2.1 [[Call]] when encountering a classConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Do not use kNear jump on x64 Created 5 years, 1 month 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
« no previous file with comments | « test/mjsunit/array-iteration.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-sloppy 5 // Flags: --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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 618
619 (function TestDefaultConstructorNoCrash() { 619 (function TestDefaultConstructorNoCrash() {
620 // Regression test for https://code.google.com/p/v8/issues/detail?id=3661 620 // Regression test for https://code.google.com/p/v8/issues/detail?id=3661
621 class C {} 621 class C {}
622 assertThrows(function () {C();}, TypeError); 622 assertThrows(function () {C();}, TypeError);
623 assertThrows(function () {C(1);}, TypeError); 623 assertThrows(function () {C(1);}, TypeError);
624 assertTrue(new C() instanceof C); 624 assertTrue(new C() instanceof C);
625 assertTrue(new C(1) instanceof C); 625 assertTrue(new C(1) instanceof C);
626 })(); 626 })();
627 627
628 (function TestConstructorCall(){
629 var realmIndex = Realm.create();
630 var otherTypeError = Realm.eval(realmIndex, "TypeError");
631 var A = Realm.eval(realmIndex, '"use strict"; class A {}');
632 var instance = new A();
633 var constructor = instance.constructor;
634 var otherTypeError = Realm.eval(realmIndex, 'TypeError');
635 if (otherTypeError === TypeError) {
636 throw Error('Should not happen!');
637 }
638
639 // ES6 9.2.1[[Call]] throws a TypeError in the caller context/Realm when the
640 // called function is a classConstructor
641 assertThrows(function() { Realm.eval(realmIndex, "A()") }, otherTypeError);
642 assertThrows(function() { instance.constructor() }, TypeError);
643 assertThrows(function() { A() }, TypeError);
644
645 // ES6 9.3.1 call() first activates the callee context before invoking the
646 // method. The TypeError from the constructor is thus thrown in the other
647 // Realm.
648 assertThrows(function() { Realm.eval(realmIndex, "A.call()") },
649 otherTypeError);
650 assertThrows(function() { constructor.call() }, otherTypeError);
651 assertThrows(function() { A.call() }, otherTypeError);
652 })();
628 653
629 (function TestDefaultConstructor() { 654 (function TestDefaultConstructor() {
630 var calls = 0; 655 var calls = 0;
631 class Base { 656 class Base {
632 constructor() { 657 constructor() {
633 calls++; 658 calls++;
634 } 659 }
635 } 660 }
636 class Derived extends Base {} 661 class Derived extends Base {}
637 var object = new Derived; 662 var object = new Derived;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 testClassRestrictedProperties(ClassWithDefaultConstructor); 964 testClassRestrictedProperties(ClassWithDefaultConstructor);
940 testClassRestrictedProperties(Class); 965 testClassRestrictedProperties(Class);
941 testClassRestrictedProperties(DerivedClassWithDefaultConstructor); 966 testClassRestrictedProperties(DerivedClassWithDefaultConstructor);
942 testClassRestrictedProperties(DerivedClass); 967 testClassRestrictedProperties(DerivedClass);
943 testClassRestrictedProperties(class { method() {} }); 968 testClassRestrictedProperties(class { method() {} });
944 testClassRestrictedProperties(class { constructor() {} method() {} }); 969 testClassRestrictedProperties(class { constructor() {} method() {} });
945 testClassRestrictedProperties(class extends Class { }); 970 testClassRestrictedProperties(class extends Class { });
946 testClassRestrictedProperties( 971 testClassRestrictedProperties(
947 class extends Class { constructor() { super(); } }); 972 class extends Class { constructor() { super(); } });
948 })(); 973 })();
OLDNEW
« no previous file with comments | « test/mjsunit/array-iteration.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698