Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | function testInt(n, result) { |
michael@0 | 7 | var x = 0; |
michael@0 | 8 | for (var i = 0; i < 15; i++) { |
michael@0 | 9 | assertEq(parseInt(n, 10), result); |
michael@0 | 10 | assertEq(parseInt(n, 0), result); |
michael@0 | 11 | assertEq(parseInt(n), result); |
michael@0 | 12 | assertEq(parseInt(n, x), result); |
michael@0 | 13 | |
michael@0 | 14 | if (x % 2 == 0) |
michael@0 | 15 | x = 10; |
michael@0 | 16 | else |
michael@0 | 17 | x = 0; |
michael@0 | 18 | } |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | function testDouble(n, result) { |
michael@0 | 22 | var x = 0; |
michael@0 | 23 | for (var i = 0; i < 15; i++) { |
michael@0 | 24 | assertEq(parseInt(n, 10), result); |
michael@0 | 25 | assertEq(parseInt(n, 0), result); |
michael@0 | 26 | assertEq(parseInt(n), result); |
michael@0 | 27 | assertEq(parseInt(n, x), result); |
michael@0 | 28 | |
michael@0 | 29 | if (x % 2 == 0) |
michael@0 | 30 | x = 10; |
michael@0 | 31 | else |
michael@0 | 32 | x = 0; |
michael@0 | 33 | } |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | testInt(2147483647, 2147483647); |
michael@0 | 37 | testInt(-2147483648, -2147483648); |
michael@0 | 38 | testInt(17, 17); |
michael@0 | 39 | testInt(-1, -1); |
michael@0 | 40 | testInt(0, 0); |
michael@0 | 41 | |
michael@0 | 42 | testDouble(1e21, 1); |
michael@0 | 43 | testDouble(-5.7, -5); |
michael@0 | 44 | testDouble(1.7, 1); |
michael@0 | 45 | testDouble(1.0e-6, 0); |
michael@0 | 46 | testDouble(1.0e-7, 1); |
michael@0 | 47 | testDouble(NaN, NaN); |
michael@0 | 48 | testDouble(1e20, 1e20); |