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

Unified Diff: test/mjsunit/harmony/new-target.js

Issue 1191973004: Work In Progress: support new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/new-target.js
diff --git a/test/mjsunit/harmony/new-target.js b/test/mjsunit/harmony/new-target.js
new file mode 100644
index 0000000000000000000000000000000000000000..99c2de0fccf0395c319e08d91d3d60bc589a02dc
--- /dev/null
+++ b/test/mjsunit/harmony/new-target.js
@@ -0,0 +1,89 @@
+// 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-classes --harmony-new-target --harmony-reflect
+// Flags: --harmony-rest-parameters
+
+'use strict';
+
+
+(function TestBasics() {
+ class Base {}
+ class Derived extends Base {
+ constructor(expected) {
+ super();
+ assertEquals(expected, new.target);
+ }
+ }
+ new Derived(Derived);
+
+ class Derived2 extends Derived {}
+ new Derived2(Derived2);
+})();
+
+
+(function TestFunctionCall() {
+ function f(expected) {
+ assertEquals(expected, new.target);
+ }
+
+ f(undefined);
+ f();
+
+ f(undefined, 'extra');
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails. `expected` ends up as the 'extra'.
+
+ f.call({}, undefined);
+ f.apply({}, [undefined]);
+})();
+
+
+(function TestFunctionRest() {
+ function f(...rest) {
+ assertEquals(rest[0], new.target);
+ }
+
+ new f(f);
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails.
+ new f(f, 'extra');
+
+ f(undefined);
+ f(undefined, 'extra');
+})();
+
+
+(function TestReflectConstruct() {
+ function f(expected) {
+ assertEquals(expected, new.target);
+ }
+
+ Reflect.construct(f, [f]);
+ Reflect.construct(f, [f], f);
+ Reflect.construct(f, [f, 'extra']);
+ Reflect.construct(f, [f, 'extra'], f);
+})();
+
+
+(function TestExtendsFunction() {
+ function Base() {
+ assertEquals(Derived, new.target);
+ }
+
+ class Derived extends Base {
+ constructor() {
+ super();
+ }
+ }
+
+ new Derived();
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails too...
+})();
+
+
+(function TestExtendsFunctionDefaultConstructor() {
+ function Base() {
+ assertEquals(Derived, new.target);
+ }
+
+ class Derived extends Base {}
+
+ new Derived();
+})();
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698