Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = "(none)";
8 var summary = "Fibonacci generator by matrix multiplication";
9 var actual, expect;
11 printBugNumber(BUGNUMBER);
12 printStatus(summary);
14 /**************
15 * BEGIN TEST *
16 **************/
18 function fib()
19 {
20 var init = [1, 0];
21 var mx = [[1, 1], [1, 0]];
22 while (true)
23 {
24 yield init[1];
25 var tmp = [,];
26 tmp[0] =
27 mx[0][0]*init[0] + mx[0][1]*init[1];
28 tmp[1] =
29 mx[1][0]*init[0] + mx[1][1]*init[1];
30 init = tmp;
31 }
32 }
34 var failed = false;
35 var it = fib();
37 try
38 {
39 if (it.next() != 0)
40 throw "F_0 failed";
41 if (it.next() != 1)
42 throw "F_1 failed";
43 if (it.next() != 1)
44 throw "F_2 failed";
45 if (it.next() != 2)
46 throw "F_3 failed";
47 if (it.next() != 3)
48 throw "F_4 failed";
49 if (it.next() != 5)
50 throw "F_5 failed";
51 if (it.next() != 8)
52 throw "F_6 failed";
53 }
54 catch (e)
55 {
56 failed = e;
57 }
61 expect = false;
62 actual = failed;
64 reportCompare(expect, actual, summary);