mirror of https://github.com/tc39/test262.git
Generate tests
This commit is contained in:
parent
dde90bf178
commit
9d5aa7d267
|
@ -4,7 +4,7 @@
|
||||||
/*---
|
/*---
|
||||||
description: Private Async Generator (private method definitions in a class expression)
|
description: Private Async Generator (private method definitions in a class expression)
|
||||||
esid: prod-MethodDefinition
|
esid: prod-MethodDefinition
|
||||||
features: [async-iteration]
|
features: [async-iteration, class, class-methods-private]
|
||||||
flags: [generated, async]
|
flags: [generated, async]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
|
@ -77,8 +77,12 @@ var ctorPromise;
|
||||||
* 2. the template provides c.ref/other.ref for external reference
|
* 2. the template provides c.ref/other.ref for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var C = class {
|
var C = class {
|
||||||
|
@ -88,12 +92,9 @@ var C = class {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
var ctorIter = this.#m();
|
var ctorIter = this.#m();
|
||||||
var p = ctorIter.next();
|
var p = ctorIter.next();
|
||||||
|
@ -109,20 +110,9 @@ var C = class {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -134,6 +124,7 @@ assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on ev
|
||||||
|
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
ctorPromise.then(() => {
|
ctorPromise.then(() => {
|
||||||
|
// gets the returned async iterator from #m
|
||||||
var iter = c.ref();
|
var iter = c.ref();
|
||||||
return iter.next().then(({ value, done }) => {
|
return iter.next().then(({ value, done }) => {
|
||||||
assert.sameValue(value, 42, 'return from generator method');
|
assert.sameValue(value, 42, 'return from generator method');
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/*---
|
/*---
|
||||||
description: Private Async Method (private method definitions in a class expression)
|
description: Private Async Method (private method definitions in a class expression)
|
||||||
esid: prod-MethodDefinition
|
esid: prod-MethodDefinition
|
||||||
features: [async-functions]
|
features: [async-functions, class, class-methods-private]
|
||||||
flags: [generated, async]
|
flags: [generated, async]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
|
@ -77,8 +77,12 @@ var ctorPromise;
|
||||||
* 2. the template provides c.ref/other.ref for external reference
|
* 2. the template provides c.ref/other.ref for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var C = class {
|
var C = class {
|
||||||
|
@ -88,12 +92,9 @@ var C = class {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
||||||
ctorPromise = this.#m().then(value => {
|
ctorPromise = this.#m().then(value => {
|
||||||
|
@ -106,20 +107,9 @@ var C = class {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -131,6 +121,7 @@ assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on ev
|
||||||
|
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
ctorPromise.then(() => {
|
ctorPromise.then(() => {
|
||||||
|
// gets the returned promise from #m
|
||||||
return c.ref().then(value => {
|
return c.ref().then(value => {
|
||||||
assert.sameValue(value, 42, 'function return');
|
assert.sameValue(value, 42, 'function return');
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/*---
|
/*---
|
||||||
description: Private Generator (private method definitions in a class expression)
|
description: Private Generator (private method definitions in a class expression)
|
||||||
esid: prod-MethodDefinition
|
esid: prod-MethodDefinition
|
||||||
features: [generators]
|
features: [generators, class, class-methods-private]
|
||||||
flags: [generated]
|
flags: [generated]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
|
@ -75,8 +75,12 @@ info: |
|
||||||
* 2. the template provides c.ref/other.ref for external reference
|
* 2. the template provides c.ref/other.ref for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var C = class {
|
var C = class {
|
||||||
|
@ -86,12 +90,9 @@ var C = class {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
var res = this.#m().next();
|
var res = this.#m().next();
|
||||||
assert.sameValue(res.value, 42, 'return from generator method, inside ctor');
|
assert.sameValue(res.value, 42, 'return from generator method, inside ctor');
|
||||||
|
@ -104,20 +105,9 @@ var C = class {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -127,6 +117,7 @@ assert.sameValue(
|
||||||
*/
|
*/
|
||||||
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
||||||
|
|
||||||
|
// gets the returned iterator from #m
|
||||||
var res = c.ref().next();
|
var res = c.ref().next();
|
||||||
assert.sameValue(res.value, 42, 'return from generator method');
|
assert.sameValue(res.value, 42, 'return from generator method');
|
||||||
assert.sameValue(res.done, true, 'iterator is done');
|
assert.sameValue(res.done, true, 'iterator is done');
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
/*---
|
/*---
|
||||||
description: Private Method (private method definitions in a class expression)
|
description: Private Method (private method definitions in a class expression)
|
||||||
esid: prod-MethodDefinition
|
esid: prod-MethodDefinition
|
||||||
|
features: [class, class-methods-private]
|
||||||
flags: [generated]
|
flags: [generated]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
|
@ -74,8 +75,12 @@ info: |
|
||||||
* 2. the template provides c.ref/other.ref for external reference
|
* 2. the template provides c.ref/other.ref for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
var C = class {
|
var C = class {
|
||||||
|
@ -85,12 +90,9 @@ var C = class {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
assert.sameValue(this.#m(), 42, 'already defined in the ctor');
|
assert.sameValue(this.#m(), 42, 'already defined in the ctor');
|
||||||
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
||||||
|
@ -101,20 +103,9 @@ var C = class {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -124,5 +115,6 @@ assert.sameValue(
|
||||||
*/
|
*/
|
||||||
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
||||||
|
|
||||||
|
// gets the returned value from #m
|
||||||
assert.sameValue(c.ref(), 42, 'function return');
|
assert.sameValue(c.ref(), 42, 'function return');
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
|
|
|
@ -76,8 +76,12 @@ var ctorPromise;
|
||||||
* the template provides c.ref() for external reference
|
* the template provides c.ref() for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
|
@ -87,12 +91,9 @@ class C {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
var ctorIter = this.#m();
|
var ctorIter = this.#m();
|
||||||
var p = ctorIter.next();
|
var p = ctorIter.next();
|
||||||
|
@ -108,20 +109,9 @@ class C {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -133,6 +123,7 @@ assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on ev
|
||||||
|
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
ctorPromise.then(() => {
|
ctorPromise.then(() => {
|
||||||
|
// gets the returned async iterator from #m
|
||||||
var iter = c.ref();
|
var iter = c.ref();
|
||||||
return iter.next().then(({ value, done }) => {
|
return iter.next().then(({ value, done }) => {
|
||||||
assert.sameValue(value, 42, 'return from generator method');
|
assert.sameValue(value, 42, 'return from generator method');
|
||||||
|
|
|
@ -76,8 +76,12 @@ var ctorPromise;
|
||||||
* the template provides c.ref() for external reference
|
* the template provides c.ref() for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
|
@ -87,12 +91,9 @@ class C {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
||||||
ctorPromise = this.#m().then(value => {
|
ctorPromise = this.#m().then(value => {
|
||||||
|
@ -105,20 +106,9 @@ class C {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -130,6 +120,7 @@ assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on ev
|
||||||
|
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
ctorPromise.then(() => {
|
ctorPromise.then(() => {
|
||||||
|
// gets the returned promise from #m
|
||||||
return c.ref().then(value => {
|
return c.ref().then(value => {
|
||||||
assert.sameValue(value, 42, 'function return');
|
assert.sameValue(value, 42, 'function return');
|
||||||
});
|
});
|
||||||
|
|
|
@ -74,8 +74,12 @@ info: |
|
||||||
* the template provides c.ref() for external reference
|
* the template provides c.ref() for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
|
@ -85,12 +89,9 @@ class C {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
var res = this.#m().next();
|
var res = this.#m().next();
|
||||||
assert.sameValue(res.value, 42, 'return from generator method, inside ctor');
|
assert.sameValue(res.value, 42, 'return from generator method, inside ctor');
|
||||||
|
@ -103,20 +104,9 @@ class C {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -126,6 +116,7 @@ assert.sameValue(
|
||||||
*/
|
*/
|
||||||
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
||||||
|
|
||||||
|
// gets the returned iterator from #m
|
||||||
var res = c.ref().next();
|
var res = c.ref().next();
|
||||||
assert.sameValue(res.value, 42, 'return from generator method');
|
assert.sameValue(res.value, 42, 'return from generator method');
|
||||||
assert.sameValue(res.done, true, 'iterator is done');
|
assert.sameValue(res.done, true, 'iterator is done');
|
||||||
|
|
|
@ -74,8 +74,12 @@ info: |
|
||||||
* the template provides c.ref() for external reference
|
* the template provides c.ref() for external reference
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function hasOwnProperty(obj, name) {
|
function hasProp(obj, name, expected, msg) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name);
|
var hasOwnProperty = Object.prototype.hasOwnProperty.call(obj, name);
|
||||||
|
assert.sameValue(hasOwnProperty, expected, msg);
|
||||||
|
|
||||||
|
var hasProperty = Reflect.has(obj, name);
|
||||||
|
assert.sameValue(hasProperty, expected, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
|
@ -85,12 +89,9 @@ class C {
|
||||||
get ref() { return this.#m; }
|
get ref() { return this.#m; }
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
assert.sameValue(
|
hasProp(this, '#m', false, 'private methods are defined in an special internal slot and cannot be found as own properties');
|
||||||
hasOwnProperty(this, '#m'), false,
|
|
||||||
'private methods are defined in an special internal slot and cannot be found as own properties'
|
|
||||||
);
|
|
||||||
assert.sameValue(typeof this.#m, 'function');
|
assert.sameValue(typeof this.#m, 'function');
|
||||||
assert.sameValue(this.ref(), this.#m, 'returns the same value');
|
assert.sameValue(this.ref, this.#m, 'returns the same value');
|
||||||
|
|
||||||
assert.sameValue(this.#m(), 42, 'already defined in the ctor');
|
assert.sameValue(this.#m(), 42, 'already defined in the ctor');
|
||||||
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
assert.sameValue(this.#m.name, '#m', 'function name inside constructor');
|
||||||
|
@ -101,20 +102,9 @@ class C {
|
||||||
var c = new C();
|
var c = new C();
|
||||||
var other = new C();
|
var other = new C();
|
||||||
|
|
||||||
assert.sameValue(
|
hasProp(C.prototype, '#m', false, 'method is not defined in the prototype');
|
||||||
hasOwnProperty(C.prototype, '#m'), false,
|
hasProp(C, '#m', false, 'method is not defined in the contructor');
|
||||||
'method is not defined in the prototype'
|
hasProp(c, '#m', false, 'method cannot be seen outside of the class');
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(C, '#m'), false,
|
|
||||||
'method is not defined in the contructor'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
hasOwnProperty(c, '#m'), false,
|
|
||||||
'method cannot be seen outside of the class'
|
|
||||||
);
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
* MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
@ -124,5 +114,6 @@ assert.sameValue(
|
||||||
*/
|
*/
|
||||||
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
assert.sameValue(c.ref, other.ref, 'The method is defined once, and reused on every new instance');
|
||||||
|
|
||||||
|
// gets the returned value from #m
|
||||||
assert.sameValue(c.ref(), 42, 'function return');
|
assert.sameValue(c.ref(), 42, 'function return');
|
||||||
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
assert.sameValue(c.ref.name, '#m', 'function name is preserved external reference');
|
||||||
|
|
Loading…
Reference in New Issue