Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/yield-undefined.js

raw symbols SCIP
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 var gTestfile = 'yield-undefined.js';
7 //-----------------------------------------------------------------------------
8 // Note that this syntax isn't in the most recently posted ES4 TG1 wiki export,
9 // either in the specification parts or in the grammar, so this test might be
10 // Spidermonkey-specific.
11 var BUGNUMBER = "(none)";
12 var summary = "|yield;| is equivalent to |yield undefined;| ";
13 var actual, expect;
14
15 printBugNumber(BUGNUMBER);
16 printStatus(summary);
17
18 /**************
19 * BEGIN TEST *
20 **************/
21
22 var failed = false;
23
24 function gen()
25 {
26 yield 7;
27 yield;
28 yield 3;
29 }
30
31 var it = gen();
32
33 try
34 {
35 if (it.next() != 7)
36 throw "7 not yielded";
37 if (it.next() !== undefined)
38 throw "|yield;| should be equivalent to |yield undefined;|";
39 if (it.next() != 3)
40 throw "3 not yielded";
41
42 var stopPassed = false;
43 try
44 {
45 it.next();
46 }
47 catch (e)
48 {
49 if (e === StopIteration)
50 stopPassed = true;
51 }
52
53 if (!stopPassed)
54 throw "it: missing or incorrect StopIteration";
55 }
56 catch (e)
57 {
58 failed = e;
59 }
60
61 expect = false;
62 actual = failed;
63
64 reportCompare(expect, actual, summary);