mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 08:24:23 +02:00
Generate tests
This commit is contained in:
parent
54bf16f91e
commit
5896ba49be
@ -1,17 +1,17 @@
|
|||||||
// This file was procedurally generated from the following sources:
|
// This file was procedurally generated from the following sources:
|
||||||
// - src/generators/yield-identifier-spread-strict.case
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
// - src/generators/default/class-decl-private-method.template
|
// - src/generators/default/class-decl-method.template
|
||||||
/*---
|
/*---
|
||||||
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element)
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator method as a ClassDeclaration element)
|
||||||
esid: prod-GeneratorPrivateMethod
|
esid: prod-GeneratorMethod
|
||||||
features: [object-spread, generators, class-methods-private]
|
features: [object-spread, generators]
|
||||||
flags: [generated, onlyStrict]
|
flags: [generated, onlyStrict]
|
||||||
negative:
|
negative:
|
||||||
phase: parse
|
phase: parse
|
||||||
type: SyntaxError
|
type: SyntaxError
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
PrivateMethodDefinition
|
MethodDefinition
|
||||||
|
|
||||||
MethodDefinition :
|
MethodDefinition :
|
||||||
GeneratorMethod
|
GeneratorMethod
|
||||||
@ -33,33 +33,20 @@ throw "Test262: This statement should not be evaluated.";
|
|||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
class C {
|
class C { *gen() {
|
||||||
*#gen() {
|
callCount += 1;
|
||||||
callCount += 1;
|
return {
|
||||||
return {
|
...(function() {
|
||||||
...(function() {
|
var yield;
|
||||||
var yield;
|
throw new Test262Error();
|
||||||
throw new Test262Error();
|
}()),
|
||||||
}()),
|
}
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
get gen() { return this.#gen; }
|
|
||||||
}
|
|
||||||
|
|
||||||
const c = new C();
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
var iter = gen();
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
|
||||||
var iter = c.gen();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assert.sameValue(callCount, 1);
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
// Test the private fields do not appear as properties after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
// This file was procedurally generated from the following sources:
|
// This file was procedurally generated from the following sources:
|
||||||
// - src/generators/yield-identifier-strict.case
|
// - src/generators/yield-identifier-strict.case
|
||||||
// - src/generators/default/class-decl-private-method.template
|
// - src/generators/default/class-decl-method.template
|
||||||
/*---
|
/*---
|
||||||
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element)
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator method as a ClassDeclaration element)
|
||||||
esid: prod-GeneratorPrivateMethod
|
esid: prod-GeneratorMethod
|
||||||
features: [generators, class-methods-private]
|
features: [generators]
|
||||||
flags: [generated, onlyStrict]
|
flags: [generated, onlyStrict]
|
||||||
negative:
|
negative:
|
||||||
phase: parse
|
phase: parse
|
||||||
type: SyntaxError
|
type: SyntaxError
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
PrivateMethodDefinition
|
MethodDefinition
|
||||||
|
|
||||||
MethodDefinition :
|
MethodDefinition :
|
||||||
GeneratorMethod
|
GeneratorMethod
|
||||||
@ -26,31 +26,18 @@ throw "Test262: This statement should not be evaluated.";
|
|||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
class C {
|
class C { *gen() {
|
||||||
*#gen() {
|
callCount += 1;
|
||||||
callCount += 1;
|
(function() {
|
||||||
(function() {
|
var yield;
|
||||||
var yield;
|
throw new Test262Error();
|
||||||
throw new Test262Error();
|
}())
|
||||||
}())
|
}}
|
||||||
}
|
|
||||||
get gen() { return this.#gen; }
|
|
||||||
}
|
|
||||||
|
|
||||||
const c = new C();
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
var iter = gen();
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
|
||||||
var iter = c.gen();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assert.sameValue(callCount, 1);
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
// Test the private fields do not appear as properties after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// This file was procedurally generated from the following sources:
|
// This file was procedurally generated from the following sources:
|
||||||
// - src/generators/yield-spread-arr-multiple.case
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
// - src/generators/default/class-decl-private-method.template
|
// - src/generators/default/class-decl-method.template
|
||||||
/*---
|
/*---
|
||||||
description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element)
|
description: Use yield value in a array spread position (Generator method as a ClassDeclaration element)
|
||||||
esid: prod-GeneratorPrivateMethod
|
esid: prod-GeneratorMethod
|
||||||
features: [generators, class-methods-private]
|
features: [generators]
|
||||||
flags: [generated]
|
flags: [generated]
|
||||||
includes: [compareArray.js]
|
includes: [compareArray.js]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
PrivateMethodDefinition
|
MethodDefinition
|
||||||
|
|
||||||
MethodDefinition :
|
MethodDefinition :
|
||||||
GeneratorMethod
|
GeneratorMethod
|
||||||
@ -31,22 +31,14 @@ var item;
|
|||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
class C {
|
class C { *gen() {
|
||||||
*#gen() {
|
callCount += 1;
|
||||||
callCount += 1;
|
yield [...yield yield];
|
||||||
yield [...yield yield];
|
}}
|
||||||
}
|
|
||||||
get gen() { return this.#gen; }
|
|
||||||
}
|
|
||||||
|
|
||||||
const c = new C();
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
var iter = gen();
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
|
||||||
var iter = c.gen();
|
|
||||||
|
|
||||||
iter.next(false);
|
iter.next(false);
|
||||||
item = iter.next(['a', 'b', 'c']);
|
item = iter.next(['a', 'b', 'c']);
|
||||||
@ -56,8 +48,3 @@ assert(compareArray(item.value, arr));
|
|||||||
assert.sameValue(item.done, false);
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
assert.sameValue(callCount, 1);
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
// Test the private fields do not appear as properties after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
// This file was procedurally generated from the following sources:
|
// This file was procedurally generated from the following sources:
|
||||||
// - src/generators/yield-spread-arr-single.case
|
// - src/generators/yield-spread-arr-single.case
|
||||||
// - src/generators/default/class-decl-private-method.template
|
// - src/generators/default/class-decl-method.template
|
||||||
/*---
|
/*---
|
||||||
description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element)
|
description: Use yield value in a array spread position (Generator method as a ClassDeclaration element)
|
||||||
esid: prod-GeneratorPrivateMethod
|
esid: prod-GeneratorMethod
|
||||||
features: [generators, class-methods-private]
|
features: [generators]
|
||||||
flags: [generated]
|
flags: [generated]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
PrivateMethodDefinition
|
MethodDefinition
|
||||||
|
|
||||||
MethodDefinition :
|
MethodDefinition :
|
||||||
GeneratorMethod
|
GeneratorMethod
|
||||||
@ -28,22 +28,14 @@ var arr = ['a', 'b', 'c'];
|
|||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
class C {
|
class C { *gen() {
|
||||||
*#gen() {
|
callCount += 1;
|
||||||
callCount += 1;
|
yield [...yield];
|
||||||
yield [...yield];
|
}}
|
||||||
}
|
|
||||||
get gen() { return this.#gen; }
|
|
||||||
}
|
|
||||||
|
|
||||||
const c = new C();
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
var iter = gen();
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
|
||||||
var iter = c.gen();
|
|
||||||
|
|
||||||
iter.next(false);
|
iter.next(false);
|
||||||
var item = iter.next(arr);
|
var item = iter.next(arr);
|
||||||
@ -58,8 +50,3 @@ assert.sameValue(value[2], 'c');
|
|||||||
assert.sameValue(item.done, false);
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
assert.sameValue(callCount, 1);
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
// Test the private fields do not appear as properties after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
// This file was procedurally generated from the following sources:
|
// This file was procedurally generated from the following sources:
|
||||||
// - src/generators/yield-spread-obj.case
|
// - src/generators/yield-spread-obj.case
|
||||||
// - src/generators/default/class-decl-private-method.template
|
// - src/generators/default/class-decl-method.template
|
||||||
/*---
|
/*---
|
||||||
description: Use yield value in a object spread position (Generator private method as a ClassDeclaration element)
|
description: Use yield value in a object spread position (Generator method as a ClassDeclaration element)
|
||||||
esid: prod-GeneratorPrivateMethod
|
esid: prod-GeneratorMethod
|
||||||
features: [object-spread, generators, class-methods-private]
|
features: [object-spread, generators]
|
||||||
flags: [generated]
|
flags: [generated]
|
||||||
includes: [compareArray.js]
|
includes: [compareArray.js]
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
PrivateMethodDefinition
|
MethodDefinition
|
||||||
|
|
||||||
MethodDefinition :
|
MethodDefinition :
|
||||||
GeneratorMethod
|
GeneratorMethod
|
||||||
@ -30,26 +30,18 @@ info: |
|
|||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
|
|
||||||
class C {
|
class C { *gen() {
|
||||||
*#gen() {
|
callCount += 1;
|
||||||
callCount += 1;
|
yield {
|
||||||
yield {
|
...yield,
|
||||||
...yield,
|
y: 1,
|
||||||
y: 1,
|
...yield yield,
|
||||||
...yield yield,
|
};
|
||||||
};
|
}}
|
||||||
}
|
|
||||||
get gen() { return this.#gen; }
|
|
||||||
}
|
|
||||||
|
|
||||||
const c = new C();
|
var gen = C.prototype.gen;
|
||||||
|
|
||||||
// Test the private fields do not appear as properties before set to value
|
var iter = gen();
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
|
||||||
var iter = c.gen();
|
|
||||||
|
|
||||||
iter.next();
|
iter.next();
|
||||||
iter.next({ x: 42 });
|
iter.next({ x: 42 });
|
||||||
@ -62,8 +54,3 @@ assert.sameValue(Object.keys(item.value).length, 2);
|
|||||||
assert.sameValue(item.done, false);
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
assert.sameValue(callCount, 1);
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
// Test the private fields do not appear as properties after set to value
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
|
||||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-spread-strict.case
|
||||||
|
// - src/generators/default/class-decl-private-method.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element)
|
||||||
|
esid: prod-GeneratorPrivateMethod
|
||||||
|
features: [object-spread, generators, class-methods-private]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
PrivateMethodDefinition
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
GeneratorMethod
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod :
|
||||||
|
* PropertyName ( UniqueFormalParameters ) { GeneratorBody }
|
||||||
|
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
*#gen() {
|
||||||
|
callCount += 1;
|
||||||
|
return {
|
||||||
|
...(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
get gen() { return this.#gen; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = new C();
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties before set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
||||||
|
|
||||||
|
var iter = c.gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties after set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
@ -0,0 +1,56 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-identifier-strict.case
|
||||||
|
// - src/generators/default/class-decl-private-method.template
|
||||||
|
/*---
|
||||||
|
description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element)
|
||||||
|
esid: prod-GeneratorPrivateMethod
|
||||||
|
features: [generators, class-methods-private]
|
||||||
|
flags: [generated, onlyStrict]
|
||||||
|
negative:
|
||||||
|
phase: parse
|
||||||
|
type: SyntaxError
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
PrivateMethodDefinition
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
GeneratorMethod
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod :
|
||||||
|
* PropertyName ( UniqueFormalParameters ) { GeneratorBody }
|
||||||
|
|
||||||
|
---*/
|
||||||
|
throw "Test262: This statement should not be evaluated.";
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
*#gen() {
|
||||||
|
callCount += 1;
|
||||||
|
(function() {
|
||||||
|
var yield;
|
||||||
|
throw new Test262Error();
|
||||||
|
}())
|
||||||
|
}
|
||||||
|
get gen() { return this.#gen; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = new C();
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties before set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
||||||
|
|
||||||
|
var iter = c.gen();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties after set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
@ -0,0 +1,63 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-multiple.case
|
||||||
|
// - src/generators/default/class-decl-private-method.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element)
|
||||||
|
esid: prod-GeneratorPrivateMethod
|
||||||
|
features: [generators, class-methods-private]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
PrivateMethodDefinition
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
GeneratorMethod
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod :
|
||||||
|
* PropertyName ( UniqueFormalParameters ) { GeneratorBody }
|
||||||
|
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
var item;
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
*#gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield yield];
|
||||||
|
}
|
||||||
|
get gen() { return this.#gen; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = new C();
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties before set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
||||||
|
|
||||||
|
var iter = c.gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
item = iter.next(['a', 'b', 'c']);
|
||||||
|
item = iter.next(item.value);
|
||||||
|
|
||||||
|
assert(compareArray(item.value, arr));
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties after set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
@ -0,0 +1,65 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-arr-single.case
|
||||||
|
// - src/generators/default/class-decl-private-method.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element)
|
||||||
|
esid: prod-GeneratorPrivateMethod
|
||||||
|
features: [generators, class-methods-private]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
PrivateMethodDefinition
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
GeneratorMethod
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod :
|
||||||
|
* PropertyName ( UniqueFormalParameters ) { GeneratorBody }
|
||||||
|
|
||||||
|
|
||||||
|
Array Initializer
|
||||||
|
|
||||||
|
SpreadElement[Yield, Await]:
|
||||||
|
...AssignmentExpression[+In, ?Yield, ?Await]
|
||||||
|
---*/
|
||||||
|
var arr = ['a', 'b', 'c'];
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
*#gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield [...yield];
|
||||||
|
}
|
||||||
|
get gen() { return this.#gen; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = new C();
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties before set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
||||||
|
|
||||||
|
var iter = c.gen();
|
||||||
|
|
||||||
|
iter.next(false);
|
||||||
|
var item = iter.next(arr);
|
||||||
|
var value = item.value;
|
||||||
|
|
||||||
|
assert.notSameValue(value, arr, 'value is a new array');
|
||||||
|
assert(Array.isArray(value), 'value is an Array exotic object');
|
||||||
|
assert.sameValue(value.length, 3)
|
||||||
|
assert.sameValue(value[0], 'a');
|
||||||
|
assert.sameValue(value[1], 'b');
|
||||||
|
assert.sameValue(value[2], 'c');
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties after set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
@ -0,0 +1,69 @@
|
|||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/generators/yield-spread-obj.case
|
||||||
|
// - src/generators/default/class-decl-private-method.template
|
||||||
|
/*---
|
||||||
|
description: Use yield value in a object spread position (Generator private method as a ClassDeclaration element)
|
||||||
|
esid: prod-GeneratorPrivateMethod
|
||||||
|
features: [object-spread, generators, class-methods-private]
|
||||||
|
flags: [generated]
|
||||||
|
includes: [compareArray.js]
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
PrivateMethodDefinition
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
GeneratorMethod
|
||||||
|
|
||||||
|
14.4 Generator Function Definitions
|
||||||
|
|
||||||
|
GeneratorMethod :
|
||||||
|
* PropertyName ( UniqueFormalParameters ) { GeneratorBody }
|
||||||
|
|
||||||
|
|
||||||
|
Spread Properties
|
||||||
|
|
||||||
|
PropertyDefinition[Yield]:
|
||||||
|
(...)
|
||||||
|
...AssignmentExpression[In, ?Yield]
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
*#gen() {
|
||||||
|
callCount += 1;
|
||||||
|
yield {
|
||||||
|
...yield,
|
||||||
|
y: 1,
|
||||||
|
...yield yield,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
get gen() { return this.#gen; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = new C();
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties before set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
||||||
|
|
||||||
|
var iter = c.gen();
|
||||||
|
|
||||||
|
iter.next();
|
||||||
|
iter.next({ x: 42 });
|
||||||
|
iter.next({ x: 'lol' });
|
||||||
|
var item = iter.next({ y: 39 });
|
||||||
|
|
||||||
|
assert.sameValue(item.value.x, 42);
|
||||||
|
assert.sameValue(item.value.y, 39);
|
||||||
|
assert.sameValue(Object.keys(item.value).length, 2);
|
||||||
|
assert.sameValue(item.done, false);
|
||||||
|
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
// Test the private fields do not appear as properties after set to value
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")');
|
||||||
|
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")');
|
Loading…
x
Reference in New Issue
Block a user