Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/nested-yield.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 = 'nested-yield.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = "(none)";
9 var summary = "YieldExpression is and contains an AssignmentExpression";
10 var actual, expect;
11
12 printBugNumber(BUGNUMBER);
13 printStatus(summary);
14
15 /**************
16 * BEGIN TEST *
17 **************/
18
19 var failed = false;
20
21 function gen()
22 {
23 yield (yield (yield 7));
24 }
25
26 var it = gen();
27
28 try
29 {
30 if (it.next() != 7)
31 throw "7 not yielded";
32 if (it.send(17) != 17)
33 throw "passed-in 17 not yielded";
34 if (it.send(undefined) !== undefined)
35 throw "should be able to yield undefined";
36
37 var stopPassed = false;
38 try
39 {
40 it.next();
41 }
42 catch (e)
43 {
44 if (e === StopIteration)
45 stopPassed = true;
46 }
47
48 if (!stopPassed)
49 throw "it: missing or incorrect StopIteration";
50 }
51 catch (e)
52 {
53 failed = e;
54 }
55
56 expect = false;
57 actual = failed;
58
59 reportCompare(expect, actual, summary);