js/src/jit-test/tests/ion/valueToInt32.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 2
michael@0 3 function f(x, y) {
michael@0 4 // Confuse the type analysis to not know the type of x.
michael@0 5 var u;
michael@0 6 var a = x + u;
michael@0 7 var b = x + 3;
michael@0 8 return x + y;
michael@0 9 }
michael@0 10
michael@0 11 function g_bool(x, y) {
michael@0 12 var t;
michael@0 13 if (x + 0)
michael@0 14 t = true;
michael@0 15 else
michael@0 16 t = false;
michael@0 17 return t + y;
michael@0 18
michael@0 19 }
michael@0 20 function g_null(x) {
michael@0 21 return null + x;
michael@0 22 }
michael@0 23
michael@0 24 assertEq(g_bool(1, 2), 3);
michael@0 25 assertEq(g_bool(0, 2), 2);
michael@0 26 assertEq(g_null(2), 2);
michael@0 27
michael@0 28 // These will not bailout.
michael@0 29 assertEq(f(Math.cos(Math.PI), 2), 1);
michael@0 30 assertEq(f(null, 2), 2);
michael@0 31 assertEq(f(false, 2), 2);
michael@0 32 assertEq(f(true, 2), 3);
michael@0 33 assertEq(f(17, 2), 19);
michael@0 34
michael@0 35 // These will bailout.
michael@0 36 assertEq(f(undefined, 2), Number.NaN);
michael@0 37 assertEq(f("20", 2), "202");
michael@0 38 assertEq(f(16.3, 2), 18.3);
michael@0 39 assertEq((1 / f(-0, -0)), -Infinity);
michael@0 40
michael@0 41

mercurial