michael@0: var a = 1.1; michael@0: function f1() { michael@0: return a + 0.2; michael@0: } michael@0: function test1() { michael@0: for (var i=0; i<100; i++) { michael@0: assertEq(f1(), 1.3); michael@0: } michael@0: a = 20; michael@0: assertEq(f1(), 20.2); michael@0: } michael@0: test1(); michael@0: michael@0: function f2(arr) { michael@0: return arr[2] + 0.2; michael@0: } michael@0: function test2() { michael@0: var a = [1.1, 2.2, 3.3, 4.4]; michael@0: for (var i=0; i<100; i++) { michael@0: assertEq(f2(a), 3.5); michael@0: } michael@0: a[2] = 123; michael@0: assertEq(f2(a), 123.2); michael@0: } michael@0: test2(); michael@0: michael@0: function f3(arr, idx) { michael@0: return arr[idx] + 0.2; michael@0: } michael@0: function test3() { michael@0: var a = [1.1, 2.2, 3.3, 4.4]; michael@0: for (var i=0; i<100; i++) { michael@0: assertEq(f3(a, 2), 3.5); michael@0: } michael@0: a[2] = 123; michael@0: assertEq(f3(a, 2), 123.2); michael@0: } michael@0: test3();