mirror of
https://github.com/tc39/test262.git
synced 2025-09-25 11:08:49 +02:00
Use sameValue in non262-generators-shell
This commit is contained in:
parent
af3d908437
commit
bfee2b57e5
@ -2,16 +2,13 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
/*---
|
/*---
|
||||||
defines: [assertFalse, assertTrue, assertNotEq, assertIteratorResult, assertIteratorNext, assertIteratorDone]
|
defines: [assertIteratorResult, assertIteratorNext, assertIteratorDone]
|
||||||
allow_unused: True
|
allow_unused: True
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function assertFalse(a) { assertEq(a, false) }
|
|
||||||
function assertTrue(a) { assertEq(a, true) }
|
|
||||||
function assertNotEq(found, not_expected) { assertEq(Object.is(found, not_expected), false) }
|
|
||||||
function assertIteratorResult(result, value, done) {
|
function assertIteratorResult(result, value, done) {
|
||||||
assert.deepEqual(result.value, value);
|
assert.sameValue(result.value, value);
|
||||||
assertEq(result.done, done);
|
assert.sameValue(result.done, done);
|
||||||
}
|
}
|
||||||
function assertIteratorNext(iter, value) {
|
function assertIteratorNext(iter, value) {
|
||||||
assertIteratorResult(iter.next(), value, false);
|
assertIteratorResult(iter.next(), value, false);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
@ -22,10 +22,10 @@ function TestGeneratorObject() {
|
|||||||
|
|
||||||
var iter = g();
|
var iter = g();
|
||||||
assert.sameValue(Object.getPrototypeOf(iter), g.prototype);
|
assert.sameValue(Object.getPrototypeOf(iter), g.prototype);
|
||||||
assertTrue(iter instanceof g);
|
assert.sameValue(iter instanceof g, true);
|
||||||
assert.sameValue(String(iter), "[object Generator]");
|
assert.sameValue(String(iter), "[object Generator]");
|
||||||
assert.deepEqual(Object.getOwnPropertyNames(iter), []);
|
assert.deepEqual(Object.getOwnPropertyNames(iter), []);
|
||||||
assertNotEq(g(), iter);
|
assert.notSameValue(g(), iter);
|
||||||
}
|
}
|
||||||
TestGeneratorObject();
|
TestGeneratorObject();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ TestGeneratorFunctionInstance();
|
|||||||
function TestGeneratorFunctionPrototype() {
|
function TestGeneratorFunctionPrototype() {
|
||||||
// Sanity check.
|
// Sanity check.
|
||||||
assert.sameValue(Object.getPrototypeOf(f), Function.prototype);
|
assert.sameValue(Object.getPrototypeOf(f), Function.prototype);
|
||||||
assertNotEq(GeneratorFunctionPrototype, Function.prototype);
|
assert.notSameValue(GeneratorFunctionPrototype, Function.prototype);
|
||||||
assert.sameValue(Object.getPrototypeOf(GeneratorFunctionPrototype),
|
assert.sameValue(Object.getPrototypeOf(GeneratorFunctionPrototype),
|
||||||
Function.prototype);
|
Function.prototype);
|
||||||
assert.sameValue(Object.getPrototypeOf(function* () {}),
|
assert.sameValue(Object.getPrototypeOf(function* () {}),
|
||||||
@ -94,27 +94,27 @@ TestGeneratorObjectPrototype();
|
|||||||
// like "Function".
|
// like "Function".
|
||||||
function TestGeneratorFunction() {
|
function TestGeneratorFunction() {
|
||||||
assert.sameValue(GeneratorFunctionPrototype, GeneratorFunction.prototype);
|
assert.sameValue(GeneratorFunctionPrototype, GeneratorFunction.prototype);
|
||||||
assertTrue(g instanceof GeneratorFunction);
|
assert.sameValue(g instanceof GeneratorFunction, true);
|
||||||
|
|
||||||
assert.sameValue(Function, Object.getPrototypeOf(GeneratorFunction));
|
assert.sameValue(Function, Object.getPrototypeOf(GeneratorFunction));
|
||||||
assertTrue(g instanceof Function);
|
assert.sameValue(g instanceof Function, true);
|
||||||
|
|
||||||
assert.sameValue("function* g() { yield 1; }", g.toString());
|
assert.sameValue("function* g() { yield 1; }", g.toString());
|
||||||
|
|
||||||
// Not all functions are generators.
|
// Not all functions are generators.
|
||||||
assertTrue(f instanceof Function); // Sanity check.
|
assert.sameValue(f instanceof Function, true); // Sanity check.
|
||||||
assertFalse(f instanceof GeneratorFunction);
|
assert.sameValue(f instanceof GeneratorFunction, false);
|
||||||
|
|
||||||
assertTrue((new GeneratorFunction()) instanceof GeneratorFunction);
|
assert.sameValue((new GeneratorFunction()) instanceof GeneratorFunction, true);
|
||||||
assertTrue(GeneratorFunction() instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction() instanceof GeneratorFunction, true);
|
||||||
|
|
||||||
assertTrue(GeneratorFunction('yield 1') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('yield 1') instanceof GeneratorFunction, true);
|
||||||
assertTrue(GeneratorFunction('return 1') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('return 1') instanceof GeneratorFunction, true);
|
||||||
assertTrue(GeneratorFunction('a', 'yield a') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('a', 'yield a') instanceof GeneratorFunction, true);
|
||||||
assertTrue(GeneratorFunction('a', 'return a') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('a', 'return a') instanceof GeneratorFunction, true);
|
||||||
assertTrue(GeneratorFunction('a', 'return a') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('a', 'return a') instanceof GeneratorFunction, true);
|
||||||
assertSyntaxError("GeneratorFunction('yield', 'return yield')");
|
assertSyntaxError("GeneratorFunction('yield', 'return yield')");
|
||||||
assertTrue(GeneratorFunction('with (x) return foo;') instanceof GeneratorFunction);
|
assert.sameValue(GeneratorFunction('with (x) return foo;') instanceof GeneratorFunction, true);
|
||||||
assertSyntaxError("GeneratorFunction('\"use strict\"; with (x) return foo;')");
|
assertSyntaxError("GeneratorFunction('\"use strict\"; with (x) return foo;')");
|
||||||
|
|
||||||
// Doesn't matter particularly what string gets serialized, as long
|
// Doesn't matter particularly what string gets serialized, as long
|
||||||
@ -126,12 +126,12 @@ TestGeneratorFunction();
|
|||||||
|
|
||||||
|
|
||||||
function TestPerGeneratorPrototype() {
|
function TestPerGeneratorPrototype() {
|
||||||
assertNotEq((function*(){}).prototype, (function*(){}).prototype);
|
assert.notSameValue((function*(){}).prototype, (function*(){}).prototype);
|
||||||
assertNotEq((function*(){}).prototype, g.prototype);
|
assert.notSameValue((function*(){}).prototype, g.prototype);
|
||||||
assert.sameValue(typeof GeneratorFunctionPrototype, "object");
|
assert.sameValue(typeof GeneratorFunctionPrototype, "object");
|
||||||
assert.sameValue(g.prototype.__proto__.constructor, GeneratorFunctionPrototype, "object");
|
assert.sameValue(g.prototype.__proto__.constructor, GeneratorFunctionPrototype, "object");
|
||||||
assert.sameValue(Object.getPrototypeOf(g.prototype), GeneratorObjectPrototype);
|
assert.sameValue(Object.getPrototypeOf(g.prototype), GeneratorObjectPrototype);
|
||||||
assertFalse(g.prototype instanceof Function);
|
assert.sameValue(g.prototype instanceof Function, false);
|
||||||
assert.sameValue(typeof (g.prototype), "object");
|
assert.sameValue(typeof (g.prototype), "object");
|
||||||
|
|
||||||
assert.deepEqual(Object.getOwnPropertyNames(g.prototype), []);
|
assert.deepEqual(Object.getOwnPropertyNames(g.prototype), []);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js, deepEqual.js]
|
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-generators-shell.js]
|
||||||
flags:
|
flags:
|
||||||
- noStrict
|
- noStrict
|
||||||
description: |
|
description: |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user