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

Side by Side Diff: test/mjsunit/harmony/class-privates-scoping.js

Issue 2329703002: Private fields
Patch Set: some comments Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 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-private-class-fields
6
7 // this
8 {
9 class C {
10 #a = this;
11 a() { return #a; }
12 }
13
14 let c = new C;
15 assertEquals(c, c.a());
16 }
17
18 // super
19 {
20 class Base {
21 m() {
22 return 0;
23 }
24 }
25
26 class Derived extends Base {
27 m() {
28 return 1;
29 }
30 #a = super.m();
31 a() { return #a; }
32 }
33
34 let c = new Derived;
35 assertEquals(0, c.a());
36 }
37
38 // new.target
39 {
40 function outer() {
41 class C {
42 #a = new.target;
43 a() { return #a; }
44 }
45
46 let c = new C;
47 assertEquals(undefined, c.a());
48 }
49
50 new outer;
51 }
52
53 // arguments
54 {
55 function outer() {
56 let stored_outer = arguments;
57 let stored_ctor;
58
59 class C {
60 #a = arguments;
61 a() { return #a; }
62
63 constructor() {
64 stored_ctor = arguments;
65 }
66 }
67
68 let c = new C;
69 assertEquals('[object Arguments]', Object.prototype.toString.call(c.a()));
70 assertFalse(stored_outer === c.a());
71 assertFalse(stored_ctor === c.a());
72 }
73
74 outer();
75 }
76
77 // ctor params
78 {
79 let b = 0;
80 class C {
81 #a = b;
82 a() { return #a; }
83
84 constructor(b) {}
85 }
86
87 let c = new C(1);
88 assertEquals(0, c.a());
89 }
90
91 // class declaration name
92 {
93 class C {
94 #a = C;
95 a() { return #a; }
96 }
97 let stored_class = C;
98 C = null;
99
100 let c = new stored_class;
101 assertEquals(stored_class, c.a());
102 }
103
104 // class expression name
105 {
106 let C = null;
107 let stored_class = class C {
108 #a = C;
109 a() { return #a; }
110 }
111
112 let c = new stored_class;
113 assertEquals(stored_class, c.a());
114 }
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/class-privates-proxy.js ('k') | test/mjsunit/harmony/class-privates-visibility.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698