| 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());
|
| +}
|
|
|