Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/message-value-passing.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 = 'message-value-passing.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 326466;
9 var summary = "Generator value/exception passing";
10 var actual, expect;
11
12 printBugNumber(BUGNUMBER);
13 printStatus(summary);
14
15 /**************
16 * BEGIN TEST *
17 **************/
18
19 function gen()
20 {
21 var rv, rv2, rv3, rv4;
22 rv = yield 1;
23
24 if (rv)
25 rv2 = yield rv;
26 else
27 rv3 = yield 2;
28
29 try
30 {
31 if (rv2)
32 yield rv2;
33 else
34 rv3 = yield 3;
35 }
36 catch (e)
37 {
38 if (e == 289)
39 yield "exception caught";
40 }
41
42 yield 5;
43 }
44
45 var failed = false;
46 var it = gen();
47
48 try
49 {
50 if (it.next() != 1)
51 throw "failed on 1";
52
53 if (it.send(17) != 17)
54 throw "failed on 17";
55
56 if (it.next() != 3)
57 throw "failed on 3";
58
59 if (it.throw(289) != "exception caught")
60 throw "it.throw(289) failed";
61
62 if (it.next() != 5)
63 throw "failed on 5";
64
65 var stopPassed = false;
66 try
67 {
68 it.next();
69 }
70 catch (e)
71 {
72 if (e === StopIteration)
73 stopPassed = true;
74 }
75
76 if (!stopPassed)
77 throw "missing or incorrect StopIteration";
78 }
79 catch (e)
80 {
81 failed = e;
82 }
83
84
85
86 expect = false;
87 actual = failed;
88
89 reportCompare(expect, actual, summary);