Generate tests

This commit is contained in:
Leo Balter 2018-10-03 18:26:13 -04:00 committed by Rick Waldron
parent 54bf16f91e
commit 5896ba49be
10 changed files with 385 additions and 132 deletions

View File

@ -1,17 +1,17 @@
// This file was procedurally generated from the following sources:
// - 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)
esid: prod-GeneratorPrivateMethod
features: [object-spread, generators, class-methods-private]
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-GeneratorMethod
features: [object-spread, generators]
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
ClassElement :
PrivateMethodDefinition
MethodDefinition
MethodDefinition :
GeneratorMethod
@ -33,33 +33,20 @@ 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; }
}
class C { *gen() {
callCount += 1;
return {
...(function() {
var yield;
throw new Test262Error();
}()),
}
}}
const c = new C();
var gen = C.prototype.gen;
// 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();
var iter = 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")');

View File

@ -1,17 +1,17 @@
// This file was procedurally generated from the following sources:
// - 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)
esid: prod-GeneratorPrivateMethod
features: [generators, class-methods-private]
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-GeneratorMethod
features: [generators]
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
ClassElement :
PrivateMethodDefinition
MethodDefinition
MethodDefinition :
GeneratorMethod
@ -26,31 +26,18 @@ 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; }
}
class C { *gen() {
callCount += 1;
(function() {
var yield;
throw new Test262Error();
}())
}}
const c = new C();
var gen = C.prototype.gen;
// 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();
var iter = 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")');

View File

@ -1,15 +1,15 @@
// This file was procedurally generated from the following sources:
// - 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)
esid: prod-GeneratorPrivateMethod
features: [generators, class-methods-private]
description: Use yield value in a array spread position (Generator method as a ClassDeclaration element)
esid: prod-GeneratorMethod
features: [generators]
flags: [generated]
includes: [compareArray.js]
info: |
ClassElement :
PrivateMethodDefinition
MethodDefinition
MethodDefinition :
GeneratorMethod
@ -31,22 +31,14 @@ var item;
var callCount = 0;
class C {
*#gen() {
callCount += 1;
yield [...yield yield];
}
get gen() { return this.#gen; }
}
class C { *gen() {
callCount += 1;
yield [...yield yield];
}}
const c = new C();
var gen = C.prototype.gen;
// 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();
var iter = gen();
iter.next(false);
item = iter.next(['a', 'b', 'c']);
@ -56,8 +48,3 @@ 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")');

View File

@ -1,14 +1,14 @@
// This file was procedurally generated from the following sources:
// - 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)
esid: prod-GeneratorPrivateMethod
features: [generators, class-methods-private]
description: Use yield value in a array spread position (Generator method as a ClassDeclaration element)
esid: prod-GeneratorMethod
features: [generators]
flags: [generated]
info: |
ClassElement :
PrivateMethodDefinition
MethodDefinition
MethodDefinition :
GeneratorMethod
@ -28,22 +28,14 @@ var arr = ['a', 'b', 'c'];
var callCount = 0;
class C {
*#gen() {
callCount += 1;
yield [...yield];
}
get gen() { return this.#gen; }
}
class C { *gen() {
callCount += 1;
yield [...yield];
}}
const c = new C();
var gen = C.prototype.gen;
// 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();
var iter = gen();
iter.next(false);
var item = iter.next(arr);
@ -58,8 +50,3 @@ 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")');

View File

@ -1,15 +1,15 @@
// This file was procedurally generated from the following sources:
// - 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)
esid: prod-GeneratorPrivateMethod
features: [object-spread, generators, class-methods-private]
description: Use yield value in a object spread position (Generator method as a ClassDeclaration element)
esid: prod-GeneratorMethod
features: [object-spread, generators]
flags: [generated]
includes: [compareArray.js]
info: |
ClassElement :
PrivateMethodDefinition
MethodDefinition
MethodDefinition :
GeneratorMethod
@ -30,26 +30,18 @@ info: |
var callCount = 0;
class C {
*#gen() {
callCount += 1;
yield {
...yield,
y: 1,
...yield yield,
};
}
get gen() { return this.#gen; }
}
class C { *gen() {
callCount += 1;
yield {
...yield,
y: 1,
...yield yield,
};
}}
const c = new C();
var gen = C.prototype.gen;
// 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();
var iter = gen();
iter.next();
iter.next({ x: 42 });
@ -62,8 +54,3 @@ 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")');

View File

@ -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")');

View File

@ -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")');

View File

@ -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")');

View File

@ -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")');

View File

@ -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")');