Skip to content
Snippets Groups Projects
Commit 3bf56527 authored by Mike Pennisi's avatar Mike Pennisi
Browse files

Improve `for..of` control flow tests

- Expand ambiguous assertion messages and assert execution paths more
  finely.
- Improve variable names in `for..of` tests
  While the object created by a GeneratorFunction may be considered an
  "iterable", it is being used as an iterator in these tests. Naming the
  variable according to the way it is used improves the readability of
  the test body.
- Add 'features' attribute to test frontmatter
- Move tests
- Introduce additional `for..of` control flow tests
parent 8af82000
No related branches found
No related tags found
No related merge requests found
Showing
with 322 additions and 33 deletions
...@@ -5,25 +5,27 @@ es6id: 13.6.4.13 S5.n ...@@ -5,25 +5,27 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `break` statements within Control flow during body evaluation should honor `break` statements within
the `catch` block of `try` statements. the `catch` block of `try` statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; $ERROR('This code is unreachable (following `yield` statement).');
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++;
try { try {
throw new Error(); throw new Error();
} catch (err) { } catch (err) {
i++;
break; break;
$ERROR('This code is unreachable (following `break` statement).');
} }
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `try` statement).');
} }
assert.sameValue(i, 1); assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `break` statements within
`finally` blocks.
features: [generators]
---*/
function* values() {
yield 1;
$ERROR('This code is unreachable (following `yield` statement).');
}
var iterator = values();
var i = 0;
for (var x of iterator) {
try {
} finally {
i++;
break;
$ERROR('This code is unreachable (following `break` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
assert.sameValue(i, 1);
...@@ -5,24 +5,25 @@ es6id: 13.6.4.13 S5.n ...@@ -5,24 +5,25 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `break` statements within Control flow during body evaluation should honor `break` statements within
`try` blocks. `try` blocks.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; $ERROR('This code is unreachable (following `yield` statement).');
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++;
try { try {
i++;
break; break;
$ERROR('This code is unreachable.');
$ERROR('This code is unreachable (following `break` statement).');
} catch (err) {} } catch (err) {}
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `try` statement).');
} }
assert.sameValue(i, 1); assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `break` statements within
`try` blocks.
features: [generators]
---*/
function* values() {
yield 1;
$ERROR('This code is unreachable (following `yield` statement).');
}
var iterator = values();
var i = 0;
outer:
while (true) {
for (var x of iterator) {
try {
throw new Error();
} catch (err) {
i++;
break outer;
$ERROR('This code is unreachable (following `break` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `break` statements within
`try` blocks.
features: [generators]
---*/
function* values() {
yield 1;
$ERROR('This code is unreachable (following `yield` statement).');
}
var iterator = values();
var i = 0;
outer:
while (true) {
for (var x of iterator) {
try {
} finally {
i++;
break outer;
$ERROR('This code is unreachable (following `break` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `break` statements within
`try` blocks.
features: [generators]
---*/
function* values() {
yield 1;
$ERROR('This code is unreachable (following `yield` statement).');
}
var iterator = values();
var i = 0;
outer:
while (true) {
for (var x of iterator) {
try {
i++;
break outer;
$ERROR('This code is unreachable (following `break` statement).');
} catch (err) {}
$ERROR('This code is unreachable (following `try` statement).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
...@@ -5,24 +5,25 @@ es6id: 13.6.4.13 S5.n ...@@ -5,24 +5,25 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor labeled `break` Control flow during body evaluation should honor labeled `break`
statements. statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; $ERROR('This code is unreachable (following `yield` statement).');
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
outer: outer:
while (true) { while (true) {
for (var x of iterable) { for (var x of iterator) {
i++; i++;
break outer; break outer;
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `break` statement).');
} }
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `for..of` statement).');
} }
assert.sameValue(i, 1); assert.sameValue(i, 1);
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
es6id: 13.6.4.13 S5.n es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `break` statements. Control flow during body evaluation should honor `break` statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; $ERROR('This code is unreachable (following `yield` statement).');
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++; i++;
break; break;
......
...@@ -5,24 +5,27 @@ es6id: 13.6.4.13 S5.n ...@@ -5,24 +5,27 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `continue` statements Control flow during body evaluation should honor `continue` statements
within the `catch` block of `try` statements. within the `catch` block of `try` statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; yield 1;
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++;
try { try {
throw new Error(); throw new Error();
} catch (err) { } catch (err) {
i++;
continue; continue;
$ERROR('This code is unreachable (following `continue` statement).');
} }
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `try` statement).');
} }
assert.sameValue(i, 2); assert.sameValue(i, 2);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `continue` statements
within the `finally` block of `try` statements.
features: [generators]
---*/
function* values() {
yield 1;
yield 1;
}
var iterator = values();
var i = 0;
for (var x of iterator) {
try {
throw new Error();
} catch (err) {
} finally {
i++;
continue;
$ERROR('This code is unreachable (following `continue` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
assert.sameValue(i, 2);
...@@ -5,23 +5,25 @@ es6id: 13.6.4.13 S5.n ...@@ -5,23 +5,25 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `continue` statements Control flow during body evaluation should honor `continue` statements
within `try` blocks. within `try` blocks.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; yield 1;
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++;
try { try {
i++;
continue; continue;
$ERROR('This code is unreachable.');
$ERROR('This code is unreachable (following `continue` statement).');
} catch (err) {} } catch (err) {}
$ERROR('This code is unreachable.'); $ERROR('This code is unreachable (following `try` statement).');
} }
assert.sameValue(i, 2); assert.sameValue(i, 2);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `continue` statements
within the `catch` block of `try` statements.
features: [generators]
---*/
function* values() {
yield 1;
yield 1;
}
var iterator = values();
var loop = true;
var i = 0;
outer:
while (loop) {
loop = false;
for (var x of iterator) {
try {
throw new Error();
} catch (err) {
i++;
continue outer;
$ERROR('This code is unreachable (following `continue` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `continue` statements
within the `finally` block of `try` statements.
features: [generators]
---*/
function* values() {
yield 1;
yield 1;
}
var iterator = values();
var loop = true;
var i = 0;
outer:
while (loop) {
loop = false;
for (var x of iterator) {
try {
throw new Error();
} catch (err) {
} finally {
i++;
continue outer;
$ERROR('This code is unreachable (following `continue` statement).');
}
$ERROR('This code is unreachable (following `try` statement).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 13.6.4.13 S5.n
description: >
Control flow during body evaluation should honor `continue` statements
within `try` blocks.
features: [generators]
---*/
function* values() {
yield 1;
yield 1;
}
var iterator = values();
var loop = true;
var i = 0;
outer:
while (loop) {
loop = false;
for (var x of iterator) {
try {
i++;
continue outer;
$ERROR('This code is unreachable (following `continue` statement).');
} catch (err) {}
$ERROR('This code is unreachable (following `try` statment).');
}
$ERROR('This code is unreachable (following `for..of` statement).');
}
assert.sameValue(i, 1);
...@@ -5,12 +5,13 @@ es6id: 13.6.4.13 S5.n ...@@ -5,12 +5,13 @@ es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor labeled `continue` Control flow during body evaluation should honor labeled `continue`
statements. statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
var loop = true; var loop = true;
...@@ -18,7 +19,7 @@ outer: ...@@ -18,7 +19,7 @@ outer:
while (loop) { while (loop) {
loop = false; loop = false;
for (var x of iterable) { for (var x of iterator) {
i++; i++;
continue outer; continue outer;
......
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
es6id: 13.6.4.13 S5.n es6id: 13.6.4.13 S5.n
description: > description: >
Control flow during body evaluation should honor `continue` statements. Control flow during body evaluation should honor `continue` statements.
features: [generators]
---*/ ---*/
function* values() { function* values() {
yield 1; yield 1;
yield 1; yield 1;
} }
var iterable = values(); var iterator = values();
var i = 0; var i = 0;
for (var x of iterable) { for (var x of iterator) {
i++; i++;
continue; continue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment