Chromium Code Reviews| Index: test/mjsunit/external-array.js |
| diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js |
| index f03f5799fa4d6c2ccd18a1fa6dec62b48b6d8a21..e5763e2ecfcff8b2760814069c3e383c9b8385a0 100644 |
| --- a/test/mjsunit/external-array.js |
| +++ b/test/mjsunit/external-array.js |
| @@ -84,6 +84,13 @@ assertEquals(3.5, get(array, 1)); |
| types = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, |
| Uint32Array, PixelArray, Float32Array, Float64Array]; |
| +test_result_nan = [0, 0, 0, 0, 0, 0, 0, NaN, NaN]; |
| +test_result_low_double = [-1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1.25, -1.25]; |
| +test_result_low_int = [-1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1, -1]; |
| +test_result_middle = [-3, 253, 253, 253, 253, 253, 254, 253.75, 253.75]; |
| +test_result_high_int = [0, 0, 256, 256, 256, 256, 255, 256, 256]; |
| +test_result_high_double = [0, 0, 256, 256, 256, 256, 255, 256.25, 256.25]; |
| + |
| const kElementCount = 40; |
| function test_load(array, sum) { |
| @@ -114,15 +121,48 @@ function test_store_const_key(array, sum) { |
| return sum; |
| } |
| -function run_test(test_func, array, expected_sum_per_run) { |
| + |
| +function test_store_middle_double(array, sum) { |
| + array[0] = 253.75; |
| + return array[0]; |
| +} |
| + |
| + |
| +function test_store_high_double(array, sum) { |
| + array[0] = 256.25; |
| + return array[0]; |
| +} |
| + |
| +function test_store_high_int(array, sum) { |
| + array[0] = 256; |
| + return array[0]; |
| +} |
| + |
| +function test_store_low_double(array, sum) { |
| + array[0] = -1.25; |
| + return array[0]; |
| +} |
| + |
| +function test_store_low_int(array, sum) { |
| + array[0] = -1; |
| + return array[0]; |
| +} |
| + |
| +function test_store_nan(array, sum) { |
| + array[0] = NaN; |
| + return array[0]; |
| +} |
| + |
|
Lasse Reichstein
2011/05/13 13:17:24
Test 0.49999999999999994, please :).
And both 1.5
danno
2011/05/15 05:50:27
I'm not so sure we should add the test case, since
Lasse Reichstein
2011/05/15 10:18:51
That's fine.
If you have a test that is known to f
danno
2011/05/16 14:13:43
I'll write and submit the test in a separate CL.
|
| +const kRuns = 10; |
| + |
| +function run_test(test_func, array, expected_result) { |
| for (var i = 0; i < 5; i++) test_func(array, 0); |
| %OptimizeFunctionOnNextCall(test_func); |
| - const kRuns = 10; |
| var sum = 0; |
| for (var i = 0; i < kRuns; i++) { |
| sum = test_func(array, sum); |
| } |
| - assertEquals(sum, expected_sum_per_run * kRuns); |
| + assertEquals(expected_result, sum); |
| %DeoptimizeFunction(test_func); |
| gc(); // Makes V8 forget about type information for test_func. |
| } |
| @@ -133,13 +173,19 @@ for (var t = 0; t < types.length; t++) { |
| for (var i = 0; i < kElementCount; i++) { |
| a[i] = i; |
| } |
| - |
| + |
| // Run test functions defined above. |
| - run_test(test_load, a, 780); |
| - run_test(test_load_const_key, a, 3); |
| - run_test(test_store, a, 820); |
| - run_test(test_store_const_key, a, 6); |
| - |
| + run_test(test_load, a, 780 * kRuns); |
| + run_test(test_load_const_key, a, 3 * kRuns); |
| + run_test(test_store, a, 820 * kRuns); |
| + run_test(test_store_const_key, a, 6 * kRuns); |
| + run_test(test_store_low_double, a, test_result_low_double[t]); |
| + run_test(test_store_low_int, a, test_result_low_int[t]); |
| + run_test(test_store_high_double, a, test_result_high_double[t]); |
| + run_test(test_store_high_int, a, test_result_high_int[t]); |
| + run_test(test_store_nan, a, test_result_nan[t]); |
| + run_test(test_store_middle_double, a, test_result_middle[t]); |
| + |
| // Test the correct behavior of the |length| property (which is read-only). |
| assertEquals(kElementCount, a.length); |
| a.length = 2; |