js/src/jit-test/tests/ion/truncateToInt32.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 w(y)
michael@0 4 {
michael@0 5 var x = 23.5;
michael@0 6 return x & y;
michael@0 7 }
michael@0 8
michael@0 9 function f(x, y) {
michael@0 10 // Confuse the type analysis to not know the type of x.
michael@0 11 var t = 3.5 + x;
michael@0 12 t + 3.5;
michael@0 13 return x & y;
michael@0 14 }
michael@0 15
michael@0 16 function g_bool(x, y) {
michael@0 17 var t;
michael@0 18 if (x + 0)
michael@0 19 t = true;
michael@0 20 else
michael@0 21 t = false;
michael@0 22 return t & y;
michael@0 23
michael@0 24 }
michael@0 25
michael@0 26 function g_null(x) {
michael@0 27 return null & x;
michael@0 28 }
michael@0 29
michael@0 30 var obj = { valueOf: function () { return 5; } }
michael@0 31
michael@0 32 assertEq(w(93), 21);
michael@0 33 assertEq(g_bool(1, 3), 1);
michael@0 34 assertEq(g_bool(0, 3), 0);
michael@0 35 assertEq(g_null(2), 0);
michael@0 36
michael@0 37 assertEq(f(1, 7), 1);
michael@0 38 assertEq(f(true, 7), 1);
michael@0 39 assertEq(f(false, 7), 0);
michael@0 40 assertEq(f("3", 7), 3);
michael@0 41 assertEq(f(obj, 7), 5);
michael@0 42 assertEq(f(3.5, 7), 3);
michael@0 43 assertEq(f(undefined, 7), 0);
michael@0 44 assertEq(f(null, 7), 0);
michael@0 45 assertEq(f(Math.NaN, 7), 0);
michael@0 46

mercurial