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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/class-privates-scoping.js
diff --git a/test/mjsunit/harmony/class-privates-scoping.js b/test/mjsunit/harmony/class-privates-scoping.js
new file mode 100644
index 0000000000000000000000000000000000000000..54d3ffe556397384765600ccabe525ad926dba1e
--- /dev/null
+++ b/test/mjsunit/harmony/class-privates-scoping.js
@@ -0,0 +1,114 @@
+// Copyright 2016 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-private-class-fields
+
+// this
+{
+ class C {
+ #a = this;
+ a() { return #a; }
+ }
+
+ let c = new C;
+ assertEquals(c, c.a());
+}
+
+// super
+{
+ class Base {
+ m() {
+ return 0;
+ }
+ }
+
+ class Derived extends Base {
+ m() {
+ return 1;
+ }
+ #a = super.m();
+ a() { return #a; }
+ }
+
+ let c = new Derived;
+ assertEquals(0, c.a());
+}
+
+// new.target
+{
+ function outer() {
+ class C {
+ #a = new.target;
+ a() { return #a; }
+ }
+
+ let c = new C;
+ assertEquals(undefined, c.a());
+ }
+
+ new outer;
+}
+
+// arguments
+{
+ function outer() {
+ let stored_outer = arguments;
+ let stored_ctor;
+
+ class C {
+ #a = arguments;
+ a() { return #a; }
+
+ constructor() {
+ stored_ctor = arguments;
+ }
+ }
+
+ let c = new C;
+ assertEquals('[object Arguments]', Object.prototype.toString.call(c.a()));
+ assertFalse(stored_outer === c.a());
+ assertFalse(stored_ctor === c.a());
+ }
+
+ outer();
+}
+
+// ctor params
+{
+ let b = 0;
+ class C {
+ #a = b;
+ a() { return #a; }
+
+ constructor(b) {}
+ }
+
+ let c = new C(1);
+ assertEquals(0, c.a());
+}
+
+// class declaration name
+{
+ class C {
+ #a = C;
+ a() { return #a; }
+ }
+ let stored_class = C;
+ C = null;
+
+ let c = new stored_class;
+ assertEquals(stored_class, c.a());
+}
+
+// class expression name
+{
+ let C = null;
+ let stored_class = class C {
+ #a = C;
+ a() { return #a; }
+ }
+
+ let c = new stored_class;
+ assertEquals(stored_class, c.a());
+}
« 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