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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-classes --harmony-new-target --harmony-reflect
6 // Flags: --harmony-rest-parameters
7
8 'use strict';
9
10
11 (function TestBasics() {
12 class Base {}
13 class Derived extends Base {
14 constructor(expected) {
15 super();
16 assertEquals(expected, new.target);
17 }
18 }
19 new Derived(Derived);
20
21 class Derived2 extends Derived {}
22 new Derived2(Derived2);
23 })();
24
25
26 (function TestFunctionCall() {
27 function f(expected) {
28 assertEquals(expected, new.target);
29 }
30
31 f(undefined);
32 f();
33
34 f(undefined, 'extra');
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails. `expected` ends up as the 'extra'.
35
36 f.call({}, undefined);
37 f.apply({}, [undefined]);
38 })();
39
40
41 (function TestFunctionRest() {
42 function f(...rest) {
43 assertEquals(rest[0], new.target);
44 }
45
46 new f(f);
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails.
47 new f(f, 'extra');
48
49 f(undefined);
50 f(undefined, 'extra');
51 })();
52
53
54 (function TestReflectConstruct() {
55 function f(expected) {
56 assertEquals(expected, new.target);
57 }
58
59 Reflect.construct(f, [f]);
60 Reflect.construct(f, [f], f);
61 Reflect.construct(f, [f, 'extra']);
62 Reflect.construct(f, [f, 'extra'], f);
63 })();
64
65
66 (function TestExtendsFunction() {
67 function Base() {
68 assertEquals(Derived, new.target);
69 }
70
71 class Derived extends Base {
72 constructor() {
73 super();
74 }
75 }
76
77 new Derived();
arv (Not doing code reviews) 2015/06/18 22:17:59 This one fails too...
78 })();
79
80
81 (function TestExtendsFunctionDefaultConstructor() {
82 function Base() {
83 assertEquals(Derived, new.target);
84 }
85
86 class Derived extends Base {}
87
88 new Derived();
89 })();
OLDNEW
« 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