built-ins/Generator*: make all indentation consistent (depth & character) (#1441)

This commit is contained in:
Rick Waldron 2018-02-15 15:25:56 -05:00 committed by Leo Balter
parent 7c66f39f41
commit e1f4ced053
46 changed files with 282 additions and 109 deletions

View File

@ -10,6 +10,6 @@ info: |
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert(Object.isExtensible(GeneratorFunction)); assert(Object.isExtensible(GeneratorFunction));

View File

@ -8,10 +8,10 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
function* gDecl() {} function* gDecl() {}
var gExpr = function* () {}; var gExpr = function*() {};
assert( assert(
gDecl instanceof GeneratorFunction, gDecl instanceof GeneratorFunction,

View File

@ -21,10 +21,10 @@ info: |
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var instance = GeneratorFunction(); var instance = GeneratorFunction();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new instance(); new instance();
}) })

View File

@ -25,7 +25,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert.sameValue(GeneratorFunction().length, 0); assert.sameValue(GeneratorFunction().length, 0);
assert.sameValue(GeneratorFunction('').length, 0); assert.sameValue(GeneratorFunction('').length, 0);

View File

@ -17,7 +17,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert.sameValue(GeneratorFunction().name, 'anonymous'); assert.sameValue(GeneratorFunction().name, 'anonymous');
verifyNotEnumerable(GeneratorFunction(), 'name'); verifyNotEnumerable(GeneratorFunction(), 'name');

View File

@ -21,7 +21,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var instance = GeneratorFunction(); var instance = GeneratorFunction();

View File

@ -17,7 +17,7 @@ info: |
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
// YieldExpression is permitted in function body. // YieldExpression is permitted in function body.
GeneratorFunction('x = yield'); GeneratorFunction('x = yield');

View File

@ -8,7 +8,7 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var g = new GeneratorFunction(); var g = new GeneratorFunction();
var iter = g(); var iter = g();

View File

@ -10,7 +10,7 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var g = GeneratorFunction('x', 'y', 'yield x + y;'); var g = GeneratorFunction('x', 'y', 'yield x + y;');
var iter = g(2, 3); var iter = g(2, 3);

View File

@ -8,7 +8,7 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var g = GeneratorFunction(); var g = GeneratorFunction();
var iter = g(); var iter = g();

View File

@ -9,7 +9,7 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var g = GeneratorFunction('yield 1;'); var g = GeneratorFunction('yield 1;');
var iter = g(); var iter = g();

View File

@ -10,7 +10,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert.sameValue(GeneratorFunction.length, 1); assert.sameValue(GeneratorFunction.length, 1);

View File

@ -20,7 +20,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert.sameValue(GeneratorFunction.name, 'GeneratorFunction'); assert.sameValue(GeneratorFunction.name, 'GeneratorFunction');

View File

@ -29,10 +29,10 @@ info: |
features: [generators, cross-realm, Reflect] features: [generators, cross-realm, Reflect]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
var other = $262.createRealm().global; var other = $262.createRealm().global;
var OtherGeneratorFunction = Object.getPrototypeOf( var OtherGeneratorFunction = Object.getPrototypeOf(
other.eval('(0, function* () {})') other.eval('(0, function* () {})')
).constructor; ).constructor;
var C = new other.Function(); var C = new other.Function();
C.prototype = null; C.prototype = null;

View File

@ -15,7 +15,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert.sameValue(GeneratorFunction.prototype.constructor, GeneratorFunction); assert.sameValue(GeneratorFunction.prototype.constructor, GeneratorFunction);

View File

@ -10,6 +10,6 @@ info: |
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
assert(Object.isExtensible(GeneratorFunction.prototype)); assert(Object.isExtensible(GeneratorFunction.prototype));

View File

@ -10,7 +10,7 @@ includes: [propertyHelper.js]
features: [generators] features: [generators]
---*/ ---*/
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
verifyNotEnumerable(GeneratorFunction, 'prototype'); verifyNotEnumerable(GeneratorFunction, 'prototype');
verifyNotWritable(GeneratorFunction, 'prototype'); verifyNotWritable(GeneratorFunction, 'prototype');

View File

@ -8,7 +8,10 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
function* g() { yield 1; yield 2; } function* g() {
yield 1;
yield 2;
}
var iter = g(); var iter = g();
var result; var result;

View File

@ -9,8 +9,13 @@ features: [generators]
---*/ ---*/
var context; var context;
function* g() { context = this; }
var obj = { g: g }; function* g() {
context = this;
}
var obj = {
g: g
};
var iter = obj.g(); var iter = obj.g();
iter.next(); iter.next();

View File

@ -37,9 +37,11 @@ features: [generators]
---*/ ---*/
var iter, result; var iter, result;
function* withoutVal() { function* withoutVal() {
iter.next(); iter.next();
} }
function* withVal() { function* withVal() {
iter.next(42); iter.next(42);
} }

View File

@ -8,7 +8,9 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
function* g() { return 23; } function* g() {
return 23;
}
var iter = g(); var iter = g();
var result; var result;

View File

@ -8,7 +8,9 @@ description: >
features: [generators] features: [generators]
---*/ ---*/
function* g() { yield 1; } function* g() {
yield 1;
}
var iter = g(); var iter = g();
var result; var result;

View File

@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call({}); }, function() {
GeneratorPrototype.next.call({});
},
'ordinary object (without value)' 'ordinary object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call({}, 1); }, function() {
GeneratorPrototype.next.call({}, 1);
},
'ordinary object (with value)' 'ordinary object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(function() {}); }, function() {
GeneratorPrototype.next.call(function() {});
},
'function object (without value)' 'function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(function() {}, 1); }, function() {
GeneratorPrototype.next.call(function() {}, 1);
},
'function object (with value)' 'function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(g); }, function() {
GeneratorPrototype.next.call(g);
},
'generator function object (without value)' 'generator function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(g, 1); }, function() {
GeneratorPrototype.next.call(g, 1);
},
'generator function object (with value)' 'generator function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(g.prototype); }, function() {
GeneratorPrototype.next.call(g.prototype);
},
'generator function prototype object (without value)' 'generator function prototype object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(g.prototype, 1); }, function() {
GeneratorPrototype.next.call(g.prototype, 1);
},
'generator function prototype object (with value)' 'generator function prototype object (with value)'
); );

View File

@ -26,66 +26,90 @@ var symbol = Symbol();
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(undefined); }, function() {
GeneratorPrototype.next.call(undefined);
},
'undefined (without value)' 'undefined (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(undefined, 1); }, function() {
GeneratorPrototype.next.call(undefined, 1);
},
'undefined (with value)' 'undefined (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(null); }, function() {
GeneratorPrototype.next.call(null);
},
'null (without value)' 'null (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(null, 1); }, function() {
GeneratorPrototype.next.call(null, 1);
},
'null (with value)' 'null (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(true); }, function() {
GeneratorPrototype.next.call(true);
},
'boolean (without value)' 'boolean (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(true, 1); }, function() {
GeneratorPrototype.next.call(true, 1);
},
'boolean (with value)' 'boolean (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call('s'); }, function() {
GeneratorPrototype.next.call('s');
},
'string (without value)' 'string (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call('s', 1); }, function() {
GeneratorPrototype.next.call('s', 1);
},
'string (with value)' 'string (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(1); }, function() {
GeneratorPrototype.next.call(1);
},
'number (without value)' 'number (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(1, 1); }, function() {
GeneratorPrototype.next.call(1, 1);
},
'number (with value)' 'number (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(symbol); }, function() {
GeneratorPrototype.next.call(symbol);
},
'symbol (without value)' 'symbol (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.next.call(symbol, 1); }, function() {
GeneratorPrototype.next.call(symbol, 1);
},
'symbol (with value)' 'symbol (with value)'
); );

View File

@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call({}); }, function() {
GeneratorPrototype.return.call({});
},
'ordinary object (without value)' 'ordinary object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call({}, 1); }, function() {
GeneratorPrototype.return.call({}, 1);
},
'ordinary object (with value)' 'ordinary object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(function() {}); }, function() {
GeneratorPrototype.return.call(function() {});
},
'function object (without value)' 'function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(function() {}, 1); }, function() {
GeneratorPrototype.return.call(function() {}, 1);
},
'function object (with value)' 'function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(g); }, function() {
GeneratorPrototype.return.call(g);
},
'generator function object (without value)' 'generator function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(g, 1); }, function() {
GeneratorPrototype.return.call(g, 1);
},
'generator function object (with value)' 'generator function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(g.prototype); }, function() {
GeneratorPrototype.return.call(g.prototype);
},
'generator function prototype object (without value)' 'generator function prototype object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(g.prototype, 1); }, function() {
GeneratorPrototype.return.call(g.prototype, 1);
},
'generator function prototype object (with value)' 'generator function prototype object (with value)'
); );

View File

@ -26,66 +26,90 @@ var symbol = Symbol();
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(undefined); }, function() {
GeneratorPrototype.return.call(undefined);
},
'undefined (without value)' 'undefined (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(undefined, 1); }, function() {
GeneratorPrototype.return.call(undefined, 1);
},
'undefined (with value)' 'undefined (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(null); }, function() {
GeneratorPrototype.return.call(null);
},
'null (without value)' 'null (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(null, 1); }, function() {
GeneratorPrototype.return.call(null, 1);
},
'null (with value)' 'null (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(true); }, function() {
GeneratorPrototype.return.call(true);
},
'boolean (without value)' 'boolean (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(true, 1); }, function() {
GeneratorPrototype.return.call(true, 1);
},
'boolean (with value)' 'boolean (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call('s'); }, function() {
GeneratorPrototype.return.call('s');
},
'string (without value)' 'string (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call('s', 1); }, function() {
GeneratorPrototype.return.call('s', 1);
},
'string (with value)' 'string (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(1); }, function() {
GeneratorPrototype.return.call(1);
},
'number (without value)' 'number (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(1, 1); }, function() {
GeneratorPrototype.return.call(1, 1);
},
'number (with value)' 'number (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(symbol); }, function() {
GeneratorPrototype.return.call(symbol);
},
'symbol (without value)' 'symbol (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.return.call(symbol, 1); }, function() {
GeneratorPrototype.return.call(symbol, 1);
},
'symbol (with value)' 'symbol (with value)'
); );

View File

@ -10,12 +10,11 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield; yield;
unreachable += 1; unreachable += 1;
try { try {} finally {}
} finally {
}
} }
var iter = g(); var iter = g();
var result; var result;

View File

@ -11,9 +11,9 @@ features: [generators]
var afterFinally = 0; var afterFinally = 0;
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {} finally {}
} finally {}
afterFinally += 1; afterFinally += 1;
yield; yield;
unreachable += 1; unreachable += 1;

View File

@ -11,11 +11,11 @@ features: [generators]
var inFinally = 0; var inFinally = 0;
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
throw new Error(); throw new Error();
try { try {} catch (e) {}
} catch (e) {}
} finally { } finally {
inFinally += 1; inFinally += 1;
yield; yield;

View File

@ -13,6 +13,7 @@ features: [generators]
var inCatch = 0; var inCatch = 0;
var inFinally = 0; var inFinally = 0;
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
try { try {
@ -29,7 +30,7 @@ function* g() {
var iter = g(); var iter = g();
var result; var result;
iter.next(); iter.next();
assert.sameValue(inCatch, 1, '`catch` code path executed'); assert.sameValue(inCatch, 1, '`catch` code path executed');
assert.sameValue(inFinally, 1, '`finally` code path executed'); assert.sameValue(inFinally, 1, '`finally` code path executed');

View File

@ -11,9 +11,9 @@ features: [generators]
var inFinally = 0; var inFinally = 0;
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {} finally {
} finally {
inFinally += 1; inFinally += 1;
yield; yield;
unreachable += 1; unreachable += 1;

View File

@ -9,13 +9,16 @@ features: [generators]
---*/ ---*/
function E() {} function E() {}
function* G() {} function* G() {}
var iter; var iter;
iter = G(); iter = G();
iter.next(); iter.next();
assert.throws(E, function() { iter.throw(new E()); }); assert.throws(E, function() {
iter.throw(new E());
});
var result = iter.next(); var result = iter.next();

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
function E() {} function E() {}
function* G() { function* G() {
yield 1; yield 1;
yield 2; yield 2;
@ -17,7 +18,9 @@ function* G() {
var iter; var iter;
iter = G(); iter = G();
assert.throws(E, function() { iter.throw(new E()); }); assert.throws(E, function() {
iter.throw(new E());
});
var result = iter.next(); var result = iter.next();

View File

@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call({}); }, function() {
GeneratorPrototype.throw.call({});
},
'ordinary object (without value)' 'ordinary object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call({}, 1); }, function() {
GeneratorPrototype.throw.call({}, 1);
},
'ordinary object (with value)' 'ordinary object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(function() {}); }, function() {
GeneratorPrototype.throw.call(function() {});
},
'function object (without value)' 'function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(function() {}, 1); }, function() {
GeneratorPrototype.throw.call(function() {}, 1);
},
'function object (with value)' 'function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(g); }, function() {
GeneratorPrototype.throw.call(g);
},
'generator function object (without value)' 'generator function object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(g, 1); }, function() {
GeneratorPrototype.throw.call(g, 1);
},
'generator function object (with value)' 'generator function object (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(g.prototype); }, function() {
GeneratorPrototype.throw.call(g.prototype);
},
'generator function prototype object (without value)' 'generator function prototype object (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(g.prototype, 1); }, function() {
GeneratorPrototype.throw.call(g.prototype, 1);
},
'generator function prototype object (with value)' 'generator function prototype object (with value)'
); );

View File

@ -26,66 +26,90 @@ var symbol = Symbol();
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(undefined); }, function() {
GeneratorPrototype.throw.call(undefined);
},
'undefined (without value)' 'undefined (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(undefined, 1); }, function() {
GeneratorPrototype.throw.call(undefined, 1);
},
'undefined (with value)' 'undefined (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(null); }, function() {
GeneratorPrototype.throw.call(null);
},
'null (without value)' 'null (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(null, 1); }, function() {
GeneratorPrototype.throw.call(null, 1);
},
'null (with value)' 'null (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(true); }, function() {
GeneratorPrototype.throw.call(true);
},
'boolean (without value)' 'boolean (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(true, 1); }, function() {
GeneratorPrototype.throw.call(true, 1);
},
'boolean (with value)' 'boolean (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call('s'); }, function() {
GeneratorPrototype.throw.call('s');
},
'string (without value)' 'string (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call('s', 1); }, function() {
GeneratorPrototype.throw.call('s', 1);
},
'string (with value)' 'string (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(1); }, function() {
GeneratorPrototype.throw.call(1);
},
'number (without value)' 'number (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(1, 1); }, function() {
GeneratorPrototype.throw.call(1, 1);
},
'number (with value)' 'number (with value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(symbol); }, function() {
GeneratorPrototype.throw.call(symbol);
},
'symbol (without value)' 'symbol (without value)'
); );
assert.throws( assert.throws(
TypeError, TypeError,
function() { GeneratorPrototype.throw.call(symbol, 1); }, function() {
GeneratorPrototype.throw.call(symbol, 1);
},
'symbol (with value)' 'symbol (with value)'
); );

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
unreachable += 1; unreachable += 1;
@ -31,7 +32,9 @@ assert.sameValue(
unreachable, 0, 'statement following `yield` not executed (paused at yield)' unreachable, 0, 'statement following `yield` not executed (paused at yield)'
); );
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -11,6 +11,7 @@ features: [generators]
var obj = {}; var obj = {};
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
try { try {
@ -41,7 +42,9 @@ result = iter.next();
assert.sameValue(result.value, 3, 'Fourth result `value`'); assert.sameValue(result.value, 3, 'Fourth result `value`');
assert.sameValue(result.done, false, 'Fourth result `done` flag'); assert.sameValue(result.done, false, 'Fourth result `done` flag');
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
try { try {
@ -38,7 +39,9 @@ result = iter.next();
assert.sameValue(result.value, exception, 'Third result `value`'); assert.sameValue(result.value, exception, 'Third result `value`');
assert.sameValue(result.done, false, 'Third result `done` flag'); assert.sameValue(result.done, false, 'Third result `done` flag');
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
unreachable += 1; unreachable += 1;
@ -33,7 +34,9 @@ assert.sameValue(
unreachable, 0, 'statement following `yield` not executed (paused at yield)' unreachable, 0, 'statement following `yield` not executed (paused at yield)'
); );
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,
@ -45,7 +48,7 @@ result = iter.next();
assert.sameValue( assert.sameValue(
result.value, undefined, 'Result `value` is undefined when done' result.value, undefined, 'Result `value` is undefined when done'
); );
assert.sameValue( result.done, true, 'Result `done` flag is `true` when done'); assert.sameValue(result.done, true, 'Result `done` flag is `true` when done');
assert.sameValue( assert.sameValue(
unreachable, 0, 'statement following `yield` not executed (once "completed")' unreachable, 0, 'statement following `yield` not executed (once "completed")'
); );

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
try { try {
@ -39,7 +40,9 @@ result = iter.next();
assert.sameValue(result.value, 4, 'Third result `value`'); assert.sameValue(result.value, 4, 'Third result `value`');
assert.sameValue(result.done, false, 'Third result `done` flag'); assert.sameValue(result.done, false, 'Third result `done` flag');
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -11,6 +11,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
yield 1; yield 1;
@ -47,7 +48,9 @@ result = iter.throw(new Test262Error());
assert.sameValue(result.value, 4, 'Fourth result `value`'); assert.sameValue(result.value, 4, 'Fourth result `value`');
assert.sameValue(result.done, false, 'Fourth result `done` flag'); assert.sameValue(result.done, false, 'Fourth result `done` flag');
assert.throws(Test262Error, function() { iter.next(); }); assert.throws(Test262Error, function() {
iter.next();
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
yield 1; yield 1;
@ -38,7 +39,9 @@ result = iter.next();
assert.sameValue(result.value, 4, 'Second result `value`'); assert.sameValue(result.value, 4, 'Second result `value`');
assert.sameValue(result.done, false, 'First result `done` flag'); assert.sameValue(result.done, false, 'First result `done` flag');
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -11,6 +11,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
yield 1; yield 1;
@ -57,7 +58,9 @@ assert.sameValue(
'statement following `yield` not executed (following `throw`)' 'statement following `yield` not executed (following `throw`)'
); );
assert.throws(Test262Error, function() { iter.next(); }); assert.throws(Test262Error, function() {
iter.next();
});
result = iter.next(); result = iter.next();
assert.sameValue( assert.sameValue(

View File

@ -11,6 +11,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
try { try {
yield 1; yield 1;
@ -43,7 +44,9 @@ assert.sameValue(
'statement following `yield` not executed (following `throw`)' 'statement following `yield` not executed (following `throw`)'
); );
assert.throws(Test262Error, function() { iter.next(); }); assert.throws(Test262Error, function() {
iter.next();
});
result = iter.next(); result = iter.next();
assert.sameValue( assert.sameValue(

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
try { try {
@ -35,7 +36,9 @@ result = iter.next();
assert.sameValue(result.value, 3, 'Third result `value`'); assert.sameValue(result.value, 3, 'Third result `value`');
assert.sameValue(result.done, false, 'Third result `done` flag'); assert.sameValue(result.done, false, 'Third result `done` flag');
assert.throws(Test262Error, function() { iter.throw(new Test262Error()); }); assert.throws(Test262Error, function() {
iter.throw(new Test262Error());
});
assert.sameValue( assert.sameValue(
unreachable, unreachable,

View File

@ -10,6 +10,7 @@ features: [generators]
---*/ ---*/
var unreachable = 0; var unreachable = 0;
function* g() { function* g() {
yield 1; yield 1;
try { try {
@ -41,7 +42,9 @@ assert.sameValue(
'statement following `yield` not executed (following `throw`)' 'statement following `yield` not executed (following `throw`)'
); );
assert.throws(Test262Error, function() { iter.next(); }); assert.throws(Test262Error, function() {
iter.next();
});
result = iter.next(); result = iter.next();
assert.sameValue( assert.sameValue(