|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 // Note that this syntax isn't in the most recently posted ES4 TG1 wiki export, |
|
8 // either in the specification parts or in the grammar, so this test might be |
|
9 // Spidermonkey-specific. |
|
10 var BUGNUMBER = "(none)"; |
|
11 var summary = "|yield;| is equivalent to |yield undefined;| "; |
|
12 var actual, expect; |
|
13 |
|
14 printBugNumber(BUGNUMBER); |
|
15 printStatus(summary); |
|
16 |
|
17 /************** |
|
18 * BEGIN TEST * |
|
19 **************/ |
|
20 |
|
21 var failed = false; |
|
22 |
|
23 function gen() |
|
24 { |
|
25 yield 7; |
|
26 yield; |
|
27 yield 3; |
|
28 } |
|
29 |
|
30 var it = gen(); |
|
31 |
|
32 try |
|
33 { |
|
34 if (it.next() != 7) |
|
35 throw "7 not yielded"; |
|
36 if (it.next() !== undefined) |
|
37 throw "|yield;| should be equivalent to |yield undefined;|"; |
|
38 if (it.next() != 3) |
|
39 throw "3 not yielded"; |
|
40 |
|
41 var stopPassed = false; |
|
42 try |
|
43 { |
|
44 it.next(); |
|
45 } |
|
46 catch (e) |
|
47 { |
|
48 if (e === StopIteration) |
|
49 stopPassed = true; |
|
50 } |
|
51 |
|
52 if (!stopPassed) |
|
53 throw "it: missing or incorrect StopIteration"; |
|
54 } |
|
55 catch (e) |
|
56 { |
|
57 failed = e; |
|
58 } |
|
59 |
|
60 expect = false; |
|
61 actual = failed; |
|
62 |
|
63 reportCompare(expect, actual, summary); |