Debian Codegraph @

rhino/testsrc/tests/js1_7/geniter/326466-01.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 = '326466-01.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 326466;
9 var summary = 'Implement Pythonic generators and iteration protocol support';
10 var actual;
11 var expect;
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 function fib()
17 {
18 var a = 0, b = 1;
19
20 while (true)
21 {
22 yield a;
23 var t = a;
24 a = b;
25 b += t;
26 }
27 }
28
29 var g = fib();
30
31 expect = '[object Generator]';
32 actual = g.toString();
33 reportCompare(expect, actual, summary);
34
35 var actual = [];
36 var expect = [0, 1, 1, 2, 3, 5, 8, 13];
37 actual.push(g.next());
38 actual.push(g.next());
39 actual.push(g.next());
40 actual.push(g.next());
41 actual.push(g.next());
42 actual.push(g.next());
43 actual.push(g.next());
44 actual.push(g.next());
45 reportCompare(expect.join(), actual.join(), summary);
46