Merge pull request #1200 from lukasmlady/regenerator-let-fn-if-bug
Add failing tests that document ES 6 generators bug
This commit is contained in:
commit
b6f18b4f2b
@ -11,3 +11,41 @@ function* foo2({ bar = 0 }) {
|
||||
|
||||
assert.equal(foo2({ bar: undefined }).next().value, 0);
|
||||
assert.equal(foo2({ bar: 3 }).next().value, 3);
|
||||
|
||||
function* foo3() {
|
||||
loop:
|
||||
while(true) {
|
||||
// Changing "let" to "var" makes the tests pass.
|
||||
let { what, value } = yield "iteration";
|
||||
|
||||
switch(what) {
|
||||
case "one":
|
||||
// Removing these 5 lines makes the tests pass.
|
||||
if(value === 1) {
|
||||
break;
|
||||
} else if(value === 2) {
|
||||
break;
|
||||
}
|
||||
|
||||
case "two":
|
||||
// Removing these 3 lines makes the tests pass.
|
||||
["a", "b"].map(function(v) {
|
||||
return value + v;
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "three":
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var gen3 = foo3();
|
||||
|
||||
assert.equal(gen3.next().value, "iteration");
|
||||
assert.equal(gen3.next({what: "one", value: 3}).done, false);
|
||||
assert.equal(gen3.next({what: "one", value: 2}).done, false);
|
||||
assert.equal(gen3.next({what: "one", value: 1}).done, false);
|
||||
assert.equal(gen3.next({what: "two", value: "sometext"}).done, false);
|
||||
assert.equal(gen3.next({what: "three"}).done, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user