Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/unreachable-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 = 'unreachable-yield.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = "(none)";
9 var summary = "Iterator with unreachable yield statement";
10 var actual, expect;
11
12 printBugNumber(BUGNUMBER);
13 printStatus(summary);
14
15 /**************
16 * BEGIN TEST *
17 **************/
18
19 function gen()
20 {
21 // this is still a generator even if yield can't
22 // be invoked, because yield is a syntactical
23 // part of the language
24 if (false)
25 yield "failed";
26 }
27
28 var failed = false;
29 try
30 {
31 var it = gen();
32 if (it == undefined)
33 throw "gen() not recognized as generator";
34
35 // no yields to execute
36 var stopPassed = false;
37 try
38 {
39 it.next();
40 }
41 catch (e)
42 {
43 if (e === StopIteration)
44 stopPassed = true;
45 }
46
47 if (!stopPassed)
48 throw "incorrect or invalid StopIteration";
49 }
50 catch (e)
51 {
52 failed = e;
53 }
54
55 expect = false;
56 actual = failed;
57
58 reportCompare(expect, actual, summary);