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

Unified Diff: test/mjsunit/harmony/class-privates-errors.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
Index: test/mjsunit/harmony/class-privates-errors.js
diff --git a/test/mjsunit/harmony/class-privates-errors.js b/test/mjsunit/harmony/class-privates-errors.js
new file mode 100644
index 0000000000000000000000000000000000000000..ee655dd13543a3b9a04f148f0bfc74aaddf1ec10
--- /dev/null
+++ b/test/mjsunit/harmony/class-privates-errors.js
@@ -0,0 +1,53 @@
+// 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
+
+// Adding the same property twice
+// TODO(bakkot) instantiating 'Base' should be an error
+{
+ class Base {
+ constructor() { return new Derived; }
+ }
+
+ class Derived extends Base {
+ #a = 0;
+ }
+}
+
+// Deleting a private field
+// TODO(bakkot) each of these lines should be a syntax error
+{
+ class C { #a; m(){ delete #a; } }
+ class D { #a; m(){ delete this.#a; } }
+}
+
+// Referencing a private field outside a class
+// TODO(bakkot) this is not spec'd to be a syntax error, but should be
+{
+ () => #a;
+ () => this.#a;
+}
+
+// Referencing a private field inside a class which doesn't declare it
+// TODO(bakkot) it is unclear whether or not this will be an error, see
+// https://github.com/tc39/proposal-private-fields/issues/49
+{
+ class C {
+ #a;
+ m(){ #b; }
+ }
+}
+
+// Referencing a private field through 'eval'
+// TODO(bakkot) it is unclear whether or not this will be an error, see
+// https://github.com/tc39/proposal-private-fields/issues/47
+{
+ class C {
+ #a = 0;
+ m() { return eval('#a'); }
+ }
+ let c = new C;
+ assertEquals(0, c.m());
+}
« no previous file with comments | « test/mjsunit/harmony/class-privates-delete.js ('k') | test/mjsunit/harmony/class-privates-evaluation-order.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698