]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | (function() { |
2 | function foo(x) { return 1 + this.f; } | |
3 | function bar(x) { return x + this.f; } | |
4 | function baz(x) { return x + 1 + this.f; } | |
5 | ||
6 | var n = 1000000; | |
7 | ||
8 | var result = (function(o) { | |
9 | var f = {fun:foo, f:1}; | |
10 | var g = {fun:bar, f:2}; | |
11 | var h = {fun:baz, f:3}; | |
12 | ||
13 | var result = 0; | |
14 | for (var i = 0; i < n; ++i) { | |
15 | if (i == n - 1) | |
16 | f = h; | |
17 | result += f.fun(o.f); | |
18 | ||
19 | var tmp = f; | |
20 | f = g; | |
21 | g = tmp; | |
22 | } | |
23 | ||
24 | return result; | |
25 | })({f:42}); | |
26 | ||
27 | if (result != ((n / 2 - 1) * (42 + 2)) + (n / 2 * (1 + 1) + (42 + 1 + 3))) | |
28 | throw "Error: bad result: " + result; | |
29 | })(); |