summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/generators/yield-error.js
blob: ac915ebcd71fb9b90c03a97b139267f398c1be89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var BUGNUMBER = 1384299;
var summary = "yield outside of generators should provide better error";

print(BUGNUMBER + ": " + summary);

let caught = false;
try {
    eval("yield 10");
} catch(e) {
    assertEq(e.message, "yield expression is only valid in generators");
    caught = true;
}
assertEq(caught, true);

try {
    eval("function f() { yield 10; }");
} catch(e) {
    assertEq(e.message, "yield expression is only valid in generators");
    caught = true;
}
assertEq(caught, true);

try {
    eval("async function f() { yield 10; }");
} catch(e) {
    assertEq(e.message, "yield expression is only valid in generators");
    caught = true;
}
assertEq(caught, true);

if (typeof reportCompare === "function")
    reportCompare(true, true);