Merge pull request #1331 from bocoup/classfields-privatename

classfields: add tests for privatename production and ASI
This commit is contained in:
Leo Balter 2017-11-03 15:19:11 -04:00 committed by GitHub
commit 8213224280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
352 changed files with 5187 additions and 0 deletions

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
async *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
async m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
*m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
static async *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
static async m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
static *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
static m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -14,6 +14,7 @@ class C {
/*{ fields }*/
m2() { return 39 }
bar = "barbaz";
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -12,6 +12,7 @@ class C {
/*{ fields }*/
foo = "foobar"
bar = "barbaz";
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/
m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/;
*m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/;
m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/; *m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
class C {
/*{ fields }*/; m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -12,6 +12,7 @@ class C {
;;;;
;;;;;;/*{ fields }*/;;;;;;;
;;;;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
async *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
async m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
*m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
static async *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
static async m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
static *m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
static m() { return 42; } /*{ fields }*/;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -14,6 +14,7 @@ var C = class {
/*{ fields }*/
m2() { return 39 }
bar = "barbaz";
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -12,6 +12,7 @@ var C = class {
/*{ fields }*/
foo = "foobar"
bar = "barbaz";
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/
m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/;
*m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -11,6 +11,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/;
m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/; *m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -10,6 +10,7 @@ esid: prod-FieldDefinition
var C = class {
/*{ fields }*/; m() { return 42; }
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -12,6 +12,7 @@ var C = class {
;;;;
;;;;;;/*{ fields }*/;;;;;;;
;;;;
/*{ privateinspectionfunctions }*/
}
var c = new C();

View File

@ -0,0 +1,50 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: static literal private names
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
template: default
---*/
//- fields
#x; #y
//- privateinspectionfunctions
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
//- assertions
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -0,0 +1,50 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: literal private names
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
template: default
---*/
//- fields
static #x; static #y
//- privateinspectionfunctions
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
//- assertions
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
*m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
*m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
*m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-gen.template
/*---
description: static literal private names (field definitions after a generator in the same line)
esid: prod-FieldDefinition
features: [generators, class-fields]
flags: [generated]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
*m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(c.m().next().value, 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(c.m, C.prototype.m);
verifyProperty(C.prototype, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
*m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
*m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
*m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-gen.template
/*---
description: literal private names (field definitions after a generator in the same line)
esid: prod-FieldDefinition
features: [generators, class-fields]
flags: [generated]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
*m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(c.m().next().value, 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(c.m, C.prototype.m);
verifyProperty(C.prototype, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
*m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-method.template
/*---
description: static literal private names (field definitions after a method in the same line)
esid: prod-FieldDefinition
features: [class-fields]
flags: [generated]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(c.m(), 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(c.m, C.prototype.m);
verifyProperty(C.prototype, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-method.template
/*---
description: literal private names (field definitions after a method in the same line)
esid: prod-FieldDefinition
features: [class-fields]
flags: [generated]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(c.m(), 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(c.m, C.prototype.m);
verifyProperty(C.prototype, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
static async *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static async *m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static async *m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,69 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-async-gen.template
/*---
description: static literal private names (field definitions after a static async generator in the same line)
esid: prod-FieldDefinition
features: [class-fields, async-iteration]
flags: [generated, async]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static async *m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
}, {restore: true});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");
C.m().next().then(function(v) {
assert.sameValue(v.value, 42);
assert.sameValue(v.done, true);
}, $DONE).then($DONE, $DONE);

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static async *m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static async *m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static async *m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,69 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-async-gen.template
/*---
description: literal private names (field definitions after a static async generator in the same line)
esid: prod-FieldDefinition
features: [class-fields, async-iteration]
flags: [generated, async]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static async *m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
}, {restore: true});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");
C.m().next().then(function(v) {
assert.sameValue(v.value, 42);
assert.sameValue(v.done, true);
}, $DONE).then($DONE, $DONE);

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static async *m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
static async m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static async m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static async m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,68 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-async-method.template
/*---
description: static literal private names (field definitions after a static async method in the same line)
esid: prod-FieldDefinition
features: [class-fields, async-functions]
flags: [generated, async]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static async m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
}, {restore: true});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");
C.m().then(function(v) {
assert.sameValue(v, 42);
}, $DONE).then($DONE, $DONE);

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static async m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static async m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static async m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,68 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-async-method.template
/*---
description: literal private names (field definitions after a static async method in the same line)
esid: prod-FieldDefinition
features: [class-fields, async-functions]
flags: [generated, async]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static async m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
}, {restore: true});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");
C.m().then(function(v) {
assert.sameValue(v, 42);
}, $DONE).then($DONE, $DONE);

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static async m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
static *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static *m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static *m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-gen.template
/*---
description: static literal private names (field definitions after a static generator in the same line)
esid: prod-FieldDefinition
features: [generators, class-fields]
flags: [generated]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static *m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(C.m().next().value, 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static *m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static *m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static *m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-gen.template
/*---
description: literal private names (field definitions after a static generator in the same line)
esid: prod-FieldDefinition
features: [generators, class-fields]
flags: [generated]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static *m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(C.m().next().value, 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static *m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -25,6 +25,7 @@ var x = "b";
var C = class {
static m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static m() { return 42; } a; b = 42;
c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-method.template
/*---
description: static literal private names (field definitions after a static method in the same line)
esid: prod-FieldDefinition
features: [class-fields]
flags: [generated]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static m() { return 42; } #x; #y;
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(C.m(), 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static m() { return 42; } static ["a"] = 42; ["a"] = 39;
}
var c = new C();

View File

@ -26,6 +26,7 @@ var y = Symbol();
var C = class {
static m() { return 42; } [x]; [y] = 42;
}
var c = new C();

View File

@ -26,6 +26,7 @@ const fn = function() {}
var C = class {
static m() { return 42; } static a; b = 42;
static c = fn;
}
var c = new C();

View File

@ -0,0 +1,65 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-expr-after-same-line-static-method.template
/*---
description: literal private names (field definitions after a static method in the same line)
esid: prod-FieldDefinition
features: [class-fields]
flags: [generated]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
static m() { return 42; } static #x; static #y;
static x() {
this.#x = 42;
return this.#x;
}
static y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(C.m(), 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false);
verifyProperty(C, "m", {
enumerable: false,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -24,6 +24,7 @@ info: |
var C = class {
static m() { return 42; } 'a'; "b"; 'c' = 39;
"d" = 42;
}
var c = new C();

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI test in field declarations -- computed name interpreted as property
esid: sec-automatic-semicolon-insertion
features: [class-fields]
---*/
var obj = {}
var C = class {
x = obj
['lol'] = 42
}
var c = new C();
assert.sameValue(c.x, 42)
assert.sameValue(obj['lol'], 42);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI test in field declarations -- computed name interpreted as string index
esid: sec-automatic-semicolon-insertion
features: [class-fields]
---*/
var C = class {
x = "lol"
[1]
}
var c = new C();
assert.sameValue(c.x, 'o');

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI test in field declarations -- error when computed name interpreted as index
esid: sec-automatic-semicolon-insertion
features: [class-fields]
negative:
phase: early
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
var C = class {
x = "string"
[0]() {}
}

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI test in field declarations -- error when generator interpreted as multiplication
esid: sec-automatic-semicolon-insertion
features: [class-fields]
negative:
phase: early
type: SyntaxError
---*/
throw "Test262: This statement should not be evaluated.";
var C = class {
x = 42
*gen() {}
}

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI test in field declarations -- field with PropertyName "in" interpreted as index
esid: sec-automatic-semicolon-insertion
features: [class-fields]
---*/
var x = 1
var y = 2
var z = [42]
var C = class {
a = x
in
z
b = y
in
z
}
var c = new C();
assert.sameValue(c.a, true, 'a = x in z')
assert.sameValue(c.a, false, 'a = y in z')
assert.sameValue(Object.hasOwnProperty.call(c, "in"), false, "'in' interpreted as index");
assert.sameValue(Object.hasOwnProperty.call(c, "z"), false, "'z' interpreted as variable");

View File

@ -29,6 +29,7 @@ var C = class {
static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]
m2() { return 39 }
bar = "barbaz";
}
var c = new C();

View File

@ -30,6 +30,7 @@ var C = class {
[x]; [y] = 42
m2() { return 39 }
bar = "barbaz";
}
var c = new C();

View File

@ -30,6 +30,7 @@ var C = class {
c = fn
m2() { return 39 }
bar = "barbaz";
}
var c = new C();

View File

@ -0,0 +1,101 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/private-names.case
// - src/class-fields/default/cls-expr-multiple-definitions.template
/*---
description: static literal private names (multiple fields definitions)
esid: prod-FieldDefinition
features: [class-fields]
flags: [generated]
info: |
ClassElement:
...
FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
#IdentifierName
---*/
var C = class {
foo = "foobar";
m() { return 42 }
#x; #y
m2() { return 39 }
bar = "barbaz";
x() {
this.#x = 42;
return this.#x;
}
y() {
this.#y = 43;
return this.#y;
}
}
var c = new C();
assert.sameValue(c.m(), 42);
assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
assert.sameValue(c.m, C.prototype.m);
verifyProperty(C.prototype, "m", {
enumerable: false,
configurable: true,
writable: true,
});
assert.sameValue(c.m2(), 39);
assert.sameValue(Object.hasOwnProperty.call(c, "m2"), false);
assert.sameValue(c.m2, C.prototype.m2);
verifyProperty(C.prototype, "m2", {
enumerable: false,
configurable: true,
writable: true,
});
assert.sameValue(c.foo, "foobar");
assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false);
verifyProperty(c, "foo", {
value: "foobar",
enumerable: true,
configurable: true,
writable: true,
});
assert.sameValue(c.bar, "barbaz");
assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false);
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false);
verifyProperty(c, "bar", {
value: "barbaz",
enumerable: true,
configurable: true,
writable: true,
});
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(c.x(), 42, "test 7");
assert.sameValue(c.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");

View File

@ -28,6 +28,7 @@ var C = class {
static ["a"] = 42; ["a"] = 39
m2() { return 39 }
bar = "barbaz";
}
var c = new C();

Some files were not shown because too many files have changed in this diff Show More