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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/array-iteration.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes.js
diff --git a/test/mjsunit/es6/classes.js b/test/mjsunit/es6/classes.js
index a1420be1c2d6c582f44bc069a310cd7dc36144d7..54cd1651566c3094f86f09d297f611d2c9e11ed2 100644
--- a/test/mjsunit/es6/classes.js
+++ b/test/mjsunit/es6/classes.js
@@ -625,6 +625,31 @@ function assertAccessorDescriptor(object, name) {
assertTrue(new C(1) instanceof C);
})();
+(function TestConstructorCall(){
+ var realmIndex = Realm.create();
+ var otherTypeError = Realm.eval(realmIndex, "TypeError");
+ var A = Realm.eval(realmIndex, '"use strict"; class A {}');
+ var instance = new A();
+ var constructor = instance.constructor;
+ var otherTypeError = Realm.eval(realmIndex, 'TypeError');
+ if (otherTypeError === TypeError) {
+ throw Error('Should not happen!');
+ }
+
+ // ES6 9.2.1[[Call]] throws a TypeError in the caller context/Realm when the
+ // called function is a classConstructor
+ assertThrows(function() { Realm.eval(realmIndex, "A()") }, otherTypeError);
+ assertThrows(function() { instance.constructor() }, TypeError);
+ assertThrows(function() { A() }, TypeError);
+
+ // ES6 9.3.1 call() first activates the callee context before invoking the
+ // method. The TypeError from the constructor is thus thrown in the other
+ // Realm.
+ assertThrows(function() { Realm.eval(realmIndex, "A.call()") },
+ otherTypeError);
+ assertThrows(function() { constructor.call() }, otherTypeError);
+ assertThrows(function() { A.call() }, otherTypeError);
+})();
(function TestDefaultConstructor() {
var calls = 0;
« 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