summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/PrivateName/names.js
blob: f71f1ac19dd75e0ebc5d5c8dfc14cefc13671428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// |reftest| shell-option(--enable-private-fields) skip-if(!xulRuntime.shell) -- requires shell-options

var C = class {
  static #field = () => 'Test262';
  static field = () => 'Test262';
  #instance = () => 'Test262';
  instance = () => 'Test262';

  static accessPrivateField() {
    return this.#field;
  }

  accessPrivateInstanceField() {
    return this.#instance;
  }

  static accessField() {
    return this.field;
  }

  accessInstanceField() {
    return this.instance;
  }
}
assertEq(C.accessPrivateField().name, '#field')
assertEq(C.accessField().name, 'field');
var c = new C;
assertEq(c.accessPrivateInstanceField().name, '#instance');
assertEq(c.accessInstanceField().name, 'instance');

if (typeof reportCompare === 'function') reportCompare(0, 0);