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

Unified Diff: test/mjsunit/es6/classes-derived-return-type.js

Issue 1571793002: Reland of Ship ES2015 sloppy-mode function hoisting, let, class (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/block-scope-class.js ('k') | test/mjsunit/harmony/block-eval-var-over-legacy-const.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes-derived-return-type.js
diff --git a/test/mjsunit/es6/classes-derived-return-type.js b/test/mjsunit/es6/classes-derived-return-type.js
new file mode 100644
index 0000000000000000000000000000000000000000..8283bcb2270f13f41f1f3bbabb00c07de69a2766
--- /dev/null
+++ b/test/mjsunit/es6/classes-derived-return-type.js
@@ -0,0 +1,90 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-sloppy
+
+
+class Base {}
+
+class DerivedWithReturn extends Base {
+ constructor(x) {
+ super();
+ return x;
+ }
+}
+
+assertThrows(function() {
+ new DerivedWithReturn(null);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturn(42);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturn(true);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturn('hi');
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturn(Symbol());
+}, TypeError);
+
+
+assertInstanceof(new DerivedWithReturn(undefined), DerivedWithReturn);
+function f() {}
+assertInstanceof(new DerivedWithReturn(new f()), f);
+assertInstanceof(new DerivedWithReturn(/re/), RegExp);
+
+
+class DerivedWithReturnNoSuper extends Base {
+ constructor(x) {
+ return x;
+ }
+}
+
+
+assertThrows(function() {
+ new DerivedWithReturnNoSuper(null);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturnNoSuper(42);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturnNoSuper(true);
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturnNoSuper('hi');
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturnNoSuper(Symbol());
+}, TypeError);
+assertThrows(function() {
+ new DerivedWithReturnNoSuper(undefined);
+}, ReferenceError);
+
+
+function f2() {}
+assertInstanceof(new DerivedWithReturnNoSuper(new f2()), f2);
+assertInstanceof(new DerivedWithReturnNoSuper(/re/), RegExp);
+
+
+class DerivedReturn extends Base {
+ constructor() {
+ super();
+ return;
+ }
+}
+
+assertInstanceof(new DerivedReturn(), DerivedReturn);
+
+
+
+class DerivedReturnThis extends Base {
+ constructor() {
+ super();
+ return this;
+ }
+}
+
+assertInstanceof(new DerivedReturnThis(), DerivedReturnThis);
« no previous file with comments | « test/mjsunit/es6/block-scope-class.js ('k') | test/mjsunit/harmony/block-eval-var-over-legacy-const.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698