Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/sequential-yields.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 = 'sequential-yields.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = "(none)";
9 var summary = "Sequential yields";
10 var actual, expect;
11
12 printBugNumber(BUGNUMBER);
13 printStatus(summary);
14
15 /**************
16 * BEGIN TEST *
17 **************/
18
19 function fib()
20 {
21 yield 0; // 0
22 yield 1; // 1
23 yield 1; // 2
24 yield 2; // 3
25 yield 3; // 4
26 yield 5; // 5
27 yield 8; // 6
28 }
29
30 var failed = false;
31 var it = fib();
32
33 try
34 {
35 if (it.next() != 0)
36 throw "0 failed";
37 if (it.next() != 1)
38 throw "1 failed";
39 if (it.next() != 1)
40 throw "2 failed";
41 if (it.next() != 2)
42 throw "3 failed";
43 if (it.next() != 3)
44 throw "4 failed";
45 if (it.next() != 5)
46 throw "5 failed";
47 if (it.next() != 8)
48 throw "6 failed";
49
50 var stopPassed = false;
51 try
52 {
53 it.next();
54 }
55 catch (e)
56 {
57 if (e === StopIteration)
58 stopPassed = true;
59 }
60 if (!stopPassed)
61 throw "missing or incorrect StopIteration";
62 }
63 catch (e)
64 {
65 failed = e;
66 }
67
68
69
70 expect = false;
71 actual = failed;
72
73 reportCompare(expect, actual, summary);