blob: bc913b2a603428eccd6cb8459f622ccb4eaec2b0 [file] [log] [blame]
utatane.tea@gmail.comb7113162017-12-18 11:49:33 +00001function assert(b) {
2 if (!b)
3 throw new Error("Bad assertion!");
4}
5noInline(assert);
6
7let value = false;
8
9function baz(x) {
10 if (typeof x !== "number") {
11 value = true;
12 }
13 return x;
14}
15noInline(baz);
16
17function bar(...args) {
18 return args;
19}
20
21let didEffects = false;
22function effects() { didEffects = true; }
23noInline(effects);
24
25function foo(a) {
26 let args = [1];
27 let theArgs = [...args, a, ...args];
28 baz(a);
29 if (value) {
30 effects();
31 }
32 let r = bar.apply(null, theArgs);
33 return r;
34}
35noInline(foo);
36
37for (let i = 0; i < 100000; i++) {
38 foo(i);
39 assert(!didEffects);
40}
41let o = {};
42let [a, b, c] = foo(o);
43assert(a === 1);
44assert(b === o);
45assert(c === 1);
46assert(didEffects);