js/src/jit-test/tests/ion/bug766218.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 // Test strict-equality with a constant boolean.
michael@0 2 function test1() {
michael@0 3 var a = [{}, false, true, 0];
michael@0 4 var res = 0;
michael@0 5
michael@0 6 for (var i=0; i<100; i++) {
michael@0 7 if (a[i % 4] === false)
michael@0 8 res += 1;
michael@0 9 }
michael@0 10 assertEq(res, 25);
michael@0 11
michael@0 12 res = 0;
michael@0 13 for (var i=0; i<100; i++) {
michael@0 14 if (true !== a[i % 4])
michael@0 15 res += 1;
michael@0 16 }
michael@0 17 assertEq(res, 75);
michael@0 18
michael@0 19 res = 0;
michael@0 20 for (var i=0; i<100; i++) {
michael@0 21 res += (a[i % 4] === true);
michael@0 22 }
michael@0 23 assertEq(res, 25);
michael@0 24
michael@0 25 res = 0;
michael@0 26 for (var i=0; i<100; i++) {
michael@0 27 res += (false !== a[i % 4]);
michael@0 28 }
michael@0 29 assertEq(res, 75);
michael@0 30 }
michael@0 31 test1();
michael@0 32
michael@0 33 // Test strict-equality with non-constant boolean.
michael@0 34 var TRUE = true;
michael@0 35 var FALSE = false;
michael@0 36
michael@0 37 function test2() {
michael@0 38 var a = [{}, false, true, 0];
michael@0 39 var res = 0;
michael@0 40
michael@0 41 for (var i=0; i<100; i++) {
michael@0 42 if (a[i % 4] === FALSE)
michael@0 43 res += 1;
michael@0 44 }
michael@0 45 assertEq(res, 25);
michael@0 46
michael@0 47 res = 0;
michael@0 48 for (var i=0; i<100; i++) {
michael@0 49 if (TRUE !== a[i % 4])
michael@0 50 res += 1;
michael@0 51 }
michael@0 52 assertEq(res, 75);
michael@0 53
michael@0 54 res = 0;
michael@0 55 for (var i=0; i<100; i++) {
michael@0 56 res += (a[i % 4] === TRUE);
michael@0 57 }
michael@0 58 assertEq(res, 25);
michael@0 59
michael@0 60 res = 0;
michael@0 61 for (var i=0; i<100; i++) {
michael@0 62 res += (FALSE !== a[i % 4]);
michael@0 63 }
michael@0 64 assertEq(res, 75);
michael@0 65 }
michael@0 66 test2();

mercurial