class fields: added tests for privatename production

This commit is contained in:
Valerie R Young 2017-10-30 00:34:05 -04:00 committed by Leo Balter
parent ce203360b1
commit 214e9969d5
No known key found for this signature in database
GPG Key ID: 2C75F319D398E36B
36 changed files with 134 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");