PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/js/src/jit-test/tests/jaeger/testSetTypedFloatArray.js

http://github.com/zpao/v8monkey
JavaScript | 61 lines | 56 code | 4 blank | 1 comment | 3 complexity | 3b3222fbba8823c62ab0db1dddedd4ec MD5 | raw file
 1// vim: set ts=4 sw=4 tw=99 et:
 2
 3function testSetTypedFloat32Array(k) {
 4    var ar = new Float32Array(8);
 5    ar[k+5] = { };
 6    ar[k+6] = ar;
 7    ar[k+4] = (k + 800) * 897 * 800 * 800 * 810 * 1923437;
 8    var t = k + 555;
 9    var L = ar[k+7] = t & 5;
10    ar[0] = 12.3;
11    ar[8] = 500;
12    ar[k+8] = 1200;
13    ar[k+1] = 500;
14    ar[k+2] = "3" + k;
15    ar[k+3] = true;
16    assertEq(ar[0] - 12.3 >= 0 &&
17             ar[0] - 12.3 <= 0.0001, true);
18    assertEq(ar[1], 500);
19    assertEq(ar[2], 30);
20    assertEq(ar[3], 1);
21    assertEq(ar[4], 715525927453369300000);
22    assertEq(ar[5], NaN);
23    assertEq(ar[6], NaN);
24    assertEq(ar[7], 1);
25    assertEq(ar[8], undefined);
26    assertEq(ar[k+8], undefined);
27}
28
29function testSetTypedFloat64Array(k) {
30    var ar = new Float64Array(8);
31    ar[k+5] = { };
32    ar[k+6] = ar;
33    ar[k+4] = (k + 800) * 897 * 800 * 800 * 810 * 1923437;
34    var t = k + 555;
35    var L = ar[k+7] = t & 5;
36    ar[0] = 12.3;
37    ar[8] = 500;
38    ar[k+8] = 1200;
39    ar[k+1] = 500;
40    ar[k+2] = "3" + k;
41    ar[k+3] = true;
42    assertEq(ar[0] - 12.3 >= 0 &&
43             ar[0] - 12.3 <= 0.0001, true);
44    assertEq(ar[1], 500);
45    assertEq(ar[2], 30);
46    assertEq(ar[3], 1);
47    assertEq(ar[4], 715525949998080000000);
48    assertEq(ar[5], NaN);
49    assertEq(ar[6], NaN);
50    assertEq(ar[7], 1);
51    assertEq(ar[8], undefined);
52    assertEq(ar[k+8], undefined);
53}
54
55for (var i = 0; i <= 10; i++) {
56    testSetTypedFloat32Array(0);
57    testSetTypedFloat64Array(0);
58    if (i == 5)
59        gc();
60}
61