mirror of https://github.com/tc39/test262.git
built-ins/Generator*: make all indentation consistent (depth & character) (#1441)
This commit is contained in:
parent
7c66f39f41
commit
e1f4ced053
|
@ -10,6 +10,6 @@ info: |
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert(Object.isExtensible(GeneratorFunction));
|
||||
|
|
|
@ -8,10 +8,10 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
function* gDecl() {}
|
||||
var gExpr = function* () {};
|
||||
var gExpr = function*() {};
|
||||
|
||||
assert(
|
||||
gDecl instanceof GeneratorFunction,
|
||||
|
|
|
@ -21,10 +21,10 @@ info: |
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var instance = GeneratorFunction();
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
new instance();
|
||||
new instance();
|
||||
})
|
||||
|
|
|
@ -25,7 +25,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert.sameValue(GeneratorFunction().length, 0);
|
||||
assert.sameValue(GeneratorFunction('').length, 0);
|
||||
|
|
|
@ -17,7 +17,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert.sameValue(GeneratorFunction().name, 'anonymous');
|
||||
verifyNotEnumerable(GeneratorFunction(), 'name');
|
||||
|
|
|
@ -21,7 +21,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var instance = GeneratorFunction();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ info: |
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
// YieldExpression is permitted in function body.
|
||||
GeneratorFunction('x = yield');
|
||||
|
|
|
@ -8,7 +8,7 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var g = new GeneratorFunction();
|
||||
var iter = g();
|
||||
|
|
|
@ -10,7 +10,7 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var g = GeneratorFunction('x', 'y', 'yield x + y;');
|
||||
var iter = g(2, 3);
|
||||
|
|
|
@ -8,7 +8,7 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var g = GeneratorFunction();
|
||||
var iter = g();
|
||||
|
|
|
@ -9,7 +9,7 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
var g = GeneratorFunction('yield 1;');
|
||||
var iter = g();
|
||||
|
|
|
@ -10,7 +10,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert.sameValue(GeneratorFunction.length, 1);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert.sameValue(GeneratorFunction.name, 'GeneratorFunction');
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ info: |
|
|||
features: [generators, cross-realm, Reflect]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
var other = $262.createRealm().global;
|
||||
var OtherGeneratorFunction = Object.getPrototypeOf(
|
||||
other.eval('(0, function* () {})')
|
||||
other.eval('(0, function* () {})')
|
||||
).constructor;
|
||||
var C = new other.Function();
|
||||
C.prototype = null;
|
||||
|
|
|
@ -15,7 +15,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert.sameValue(GeneratorFunction.prototype.constructor, GeneratorFunction);
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ info: |
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
assert(Object.isExtensible(GeneratorFunction.prototype));
|
||||
|
|
|
@ -10,7 +10,7 @@ includes: [propertyHelper.js]
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
|
||||
var GeneratorFunction = Object.getPrototypeOf(function*() {}).constructor;
|
||||
|
||||
verifyNotEnumerable(GeneratorFunction, 'prototype');
|
||||
verifyNotWritable(GeneratorFunction, 'prototype');
|
||||
|
|
|
@ -8,7 +8,10 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
function* g() { yield 1; yield 2; }
|
||||
function* g() {
|
||||
yield 1;
|
||||
yield 2;
|
||||
}
|
||||
var iter = g();
|
||||
var result;
|
||||
|
||||
|
|
|
@ -9,8 +9,13 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var context;
|
||||
function* g() { context = this; }
|
||||
var obj = { g: g };
|
||||
|
||||
function* g() {
|
||||
context = this;
|
||||
}
|
||||
var obj = {
|
||||
g: g
|
||||
};
|
||||
var iter = obj.g();
|
||||
|
||||
iter.next();
|
||||
|
|
|
@ -37,9 +37,11 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var iter, result;
|
||||
|
||||
function* withoutVal() {
|
||||
iter.next();
|
||||
}
|
||||
|
||||
function* withVal() {
|
||||
iter.next(42);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
function* g() { return 23; }
|
||||
function* g() {
|
||||
return 23;
|
||||
}
|
||||
var iter = g();
|
||||
var result;
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ description: >
|
|||
features: [generators]
|
||||
---*/
|
||||
|
||||
function* g() { yield 1; }
|
||||
function* g() {
|
||||
yield 1;
|
||||
}
|
||||
var iter = g();
|
||||
var result;
|
||||
|
||||
|
|
|
@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call({}); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call({});
|
||||
},
|
||||
'ordinary object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call({}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call({}, 1);
|
||||
},
|
||||
'ordinary object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(function() {}); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(function() {});
|
||||
},
|
||||
'function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(function() {}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(function() {}, 1);
|
||||
},
|
||||
'function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(g); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(g);
|
||||
},
|
||||
'generator function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(g, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(g, 1);
|
||||
},
|
||||
'generator function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(g.prototype); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(g.prototype);
|
||||
},
|
||||
'generator function prototype object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(g.prototype, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(g.prototype, 1);
|
||||
},
|
||||
'generator function prototype object (with value)'
|
||||
);
|
||||
|
|
|
@ -26,66 +26,90 @@ var symbol = Symbol();
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(undefined); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(undefined);
|
||||
},
|
||||
'undefined (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(undefined, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(undefined, 1);
|
||||
},
|
||||
'undefined (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(null); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(null);
|
||||
},
|
||||
'null (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(null, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(null, 1);
|
||||
},
|
||||
'null (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(true); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(true);
|
||||
},
|
||||
'boolean (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(true, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(true, 1);
|
||||
},
|
||||
'boolean (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call('s'); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call('s');
|
||||
},
|
||||
'string (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call('s', 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call('s', 1);
|
||||
},
|
||||
'string (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(1);
|
||||
},
|
||||
'number (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(1, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(1, 1);
|
||||
},
|
||||
'number (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(symbol); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(symbol);
|
||||
},
|
||||
'symbol (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.next.call(symbol, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.next.call(symbol, 1);
|
||||
},
|
||||
'symbol (with value)'
|
||||
);
|
||||
|
|
|
@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call({}); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call({});
|
||||
},
|
||||
'ordinary object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call({}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call({}, 1);
|
||||
},
|
||||
'ordinary object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(function() {}); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(function() {});
|
||||
},
|
||||
'function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(function() {}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(function() {}, 1);
|
||||
},
|
||||
'function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(g); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(g);
|
||||
},
|
||||
'generator function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(g, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(g, 1);
|
||||
},
|
||||
'generator function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(g.prototype); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(g.prototype);
|
||||
},
|
||||
'generator function prototype object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(g.prototype, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(g.prototype, 1);
|
||||
},
|
||||
'generator function prototype object (with value)'
|
||||
);
|
||||
|
|
|
@ -26,66 +26,90 @@ var symbol = Symbol();
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(undefined); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(undefined);
|
||||
},
|
||||
'undefined (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(undefined, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(undefined, 1);
|
||||
},
|
||||
'undefined (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(null); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(null);
|
||||
},
|
||||
'null (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(null, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(null, 1);
|
||||
},
|
||||
'null (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(true); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(true);
|
||||
},
|
||||
'boolean (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(true, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(true, 1);
|
||||
},
|
||||
'boolean (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call('s'); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call('s');
|
||||
},
|
||||
'string (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call('s', 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call('s', 1);
|
||||
},
|
||||
'string (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(1);
|
||||
},
|
||||
'number (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(1, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(1, 1);
|
||||
},
|
||||
'number (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(symbol); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(symbol);
|
||||
},
|
||||
'symbol (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.return.call(symbol, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.return.call(symbol, 1);
|
||||
},
|
||||
'symbol (with value)'
|
||||
);
|
||||
|
|
|
@ -10,12 +10,11 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield;
|
||||
unreachable += 1;
|
||||
try {
|
||||
} finally {
|
||||
}
|
||||
try {} finally {}
|
||||
}
|
||||
var iter = g();
|
||||
var result;
|
||||
|
|
|
@ -11,9 +11,9 @@ features: [generators]
|
|||
|
||||
var afterFinally = 0;
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
} finally {}
|
||||
try {} finally {}
|
||||
afterFinally += 1;
|
||||
yield;
|
||||
unreachable += 1;
|
||||
|
|
|
@ -11,11 +11,11 @@ features: [generators]
|
|||
|
||||
var inFinally = 0;
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
throw new Error();
|
||||
try {
|
||||
} catch (e) {}
|
||||
try {} catch (e) {}
|
||||
} finally {
|
||||
inFinally += 1;
|
||||
yield;
|
||||
|
|
|
@ -13,6 +13,7 @@ features: [generators]
|
|||
var inCatch = 0;
|
||||
var inFinally = 0;
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
try {
|
||||
|
@ -29,7 +30,7 @@ function* g() {
|
|||
var iter = g();
|
||||
var result;
|
||||
|
||||
iter.next();
|
||||
iter.next();
|
||||
|
||||
assert.sameValue(inCatch, 1, '`catch` code path executed');
|
||||
assert.sameValue(inFinally, 1, '`finally` code path executed');
|
||||
|
|
|
@ -11,9 +11,9 @@ features: [generators]
|
|||
|
||||
var inFinally = 0;
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
} finally {
|
||||
try {} finally {
|
||||
inFinally += 1;
|
||||
yield;
|
||||
unreachable += 1;
|
||||
|
|
|
@ -9,13 +9,16 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
function E() {}
|
||||
|
||||
function* G() {}
|
||||
var iter;
|
||||
|
||||
iter = G();
|
||||
iter.next();
|
||||
|
||||
assert.throws(E, function() { iter.throw(new E()); });
|
||||
assert.throws(E, function() {
|
||||
iter.throw(new E());
|
||||
});
|
||||
|
||||
var result = iter.next();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
function E() {}
|
||||
|
||||
function* G() {
|
||||
yield 1;
|
||||
yield 2;
|
||||
|
@ -17,7 +18,9 @@ function* G() {
|
|||
var iter;
|
||||
|
||||
iter = G();
|
||||
assert.throws(E, function() { iter.throw(new E()); });
|
||||
assert.throws(E, function() {
|
||||
iter.throw(new E());
|
||||
});
|
||||
|
||||
var result = iter.next();
|
||||
|
||||
|
|
|
@ -27,44 +27,60 @@ var GeneratorPrototype = Object.getPrototypeOf(g).prototype;
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call({}); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call({});
|
||||
},
|
||||
'ordinary object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call({}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call({}, 1);
|
||||
},
|
||||
'ordinary object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(function() {}); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(function() {});
|
||||
},
|
||||
'function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(function() {}, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(function() {}, 1);
|
||||
},
|
||||
'function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(g); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(g);
|
||||
},
|
||||
'generator function object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(g, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(g, 1);
|
||||
},
|
||||
'generator function object (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(g.prototype); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(g.prototype);
|
||||
},
|
||||
'generator function prototype object (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(g.prototype, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(g.prototype, 1);
|
||||
},
|
||||
'generator function prototype object (with value)'
|
||||
);
|
||||
|
|
|
@ -26,66 +26,90 @@ var symbol = Symbol();
|
|||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(undefined); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(undefined);
|
||||
},
|
||||
'undefined (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(undefined, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(undefined, 1);
|
||||
},
|
||||
'undefined (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(null); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(null);
|
||||
},
|
||||
'null (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(null, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(null, 1);
|
||||
},
|
||||
'null (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(true); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(true);
|
||||
},
|
||||
'boolean (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(true, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(true, 1);
|
||||
},
|
||||
'boolean (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call('s'); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call('s');
|
||||
},
|
||||
'string (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call('s', 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call('s', 1);
|
||||
},
|
||||
'string (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(1);
|
||||
},
|
||||
'number (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(1, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(1, 1);
|
||||
},
|
||||
'number (with value)'
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(symbol); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(symbol);
|
||||
},
|
||||
'symbol (without value)'
|
||||
);
|
||||
assert.throws(
|
||||
TypeError,
|
||||
function() { GeneratorPrototype.throw.call(symbol, 1); },
|
||||
function() {
|
||||
GeneratorPrototype.throw.call(symbol, 1);
|
||||
},
|
||||
'symbol (with value)'
|
||||
);
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
unreachable += 1;
|
||||
|
@ -31,7 +32,9 @@ assert.sameValue(
|
|||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -11,6 +11,7 @@ features: [generators]
|
|||
|
||||
var obj = {};
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
try {
|
||||
|
@ -41,7 +42,9 @@ result = iter.next();
|
|||
assert.sameValue(result.value, 3, 'Fourth result `value`');
|
||||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
try {
|
||||
|
@ -38,7 +39,9 @@ result = iter.next();
|
|||
assert.sameValue(result.value, exception, 'Third result `value`');
|
||||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
unreachable += 1;
|
||||
|
@ -33,7 +34,9 @@ assert.sameValue(
|
|||
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(
|
||||
unreachable,
|
||||
|
@ -45,7 +48,7 @@ result = iter.next();
|
|||
assert.sameValue(
|
||||
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(
|
||||
unreachable, 0, 'statement following `yield` not executed (once "completed")'
|
||||
);
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
try {
|
||||
|
@ -39,7 +40,9 @@ result = iter.next();
|
|||
assert.sameValue(result.value, 4, 'Third result `value`');
|
||||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -11,6 +11,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -47,7 +48,9 @@ result = iter.throw(new Test262Error());
|
|||
assert.sameValue(result.value, 4, 'Fourth result `value`');
|
||||
assert.sameValue(result.done, false, 'Fourth result `done` flag');
|
||||
|
||||
assert.throws(Test262Error, function() { iter.next(); });
|
||||
assert.throws(Test262Error, function() {
|
||||
iter.next();
|
||||
});
|
||||
|
||||
assert.sameValue(
|
||||
unreachable,
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -38,7 +39,9 @@ result = iter.next();
|
|||
assert.sameValue(result.value, 4, 'Second result `value`');
|
||||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -11,6 +11,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -57,7 +58,9 @@ assert.sameValue(
|
|||
'statement following `yield` not executed (following `throw`)'
|
||||
);
|
||||
|
||||
assert.throws(Test262Error, function() { iter.next(); });
|
||||
assert.throws(Test262Error, function() {
|
||||
iter.next();
|
||||
});
|
||||
|
||||
result = iter.next();
|
||||
assert.sameValue(
|
||||
|
|
|
@ -11,6 +11,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -43,7 +44,9 @@ assert.sameValue(
|
|||
'statement following `yield` not executed (following `throw`)'
|
||||
);
|
||||
|
||||
assert.throws(Test262Error, function() { iter.next(); });
|
||||
assert.throws(Test262Error, function() {
|
||||
iter.next();
|
||||
});
|
||||
|
||||
result = iter.next();
|
||||
assert.sameValue(
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
try {
|
||||
|
@ -35,7 +36,9 @@ result = iter.next();
|
|||
assert.sameValue(result.value, 3, 'Third result `value`');
|
||||
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(
|
||||
unreachable,
|
||||
|
|
|
@ -10,6 +10,7 @@ features: [generators]
|
|||
---*/
|
||||
|
||||
var unreachable = 0;
|
||||
|
||||
function* g() {
|
||||
yield 1;
|
||||
try {
|
||||
|
@ -41,7 +42,9 @@ assert.sameValue(
|
|||
'statement following `yield` not executed (following `throw`)'
|
||||
);
|
||||
|
||||
assert.throws(Test262Error, function() { iter.next(); });
|
||||
assert.throws(Test262Error, function() {
|
||||
iter.next();
|
||||
});
|
||||
|
||||
result = iter.next();
|
||||
assert.sameValue(
|
||||
|
|
Loading…
Reference in New Issue