()
| 61 | } |
| 62 | |
| 63 | function test() { |
| 64 | // Ensure that a negative zero coming from Math.trunc is properly handled |
| 65 | // by other operations. |
| 66 | function itrunc(x) { |
| 67 | return 1 / Math.trunc(x); |
| 68 | } |
| 69 | %PrepareFunctionForOptimization(itrunc); |
| 70 | assertEquals(Infinity, itrunc(0)); |
| 71 | assertEquals(-Infinity, itrunc(-0)); |
| 72 | assertEquals(Infinity, itrunc(Math.PI / 4)); |
| 73 | assertEquals(-Infinity, itrunc(-Math.sqrt(2) / 2)); |
| 74 | assertEquals(-Infinity, itrunc({valueOf: function() { return "-0.1"; }})); |
| 75 | %OptimizeFunctionOnNextCall(itrunc); |
| 76 | |
| 77 | testTrunc(100, 100); |
| 78 | testTrunc(-199, -199); |
| 79 | testTrunc(100, 100.1); |
| 80 | testTrunc(4503599627370495.0, 4503599627370495.0); |
| 81 | testTrunc(4503599627370496.0, 4503599627370496.0); |
| 82 | testTrunc(-4503599627370495.0, -4503599627370495.0); |
| 83 | testTrunc(-4503599627370496.0, -4503599627370496.0); |
| 84 | testTrunc(9007199254740991.0, 9007199254740991.0); |
| 85 | testTrunc(-9007199254740991.0, -9007199254740991.0); |
| 86 | testTrunc(0, []); |
| 87 | testTrunc(1, [1]); |
| 88 | testTrunc(-100, [-100.1]); |
| 89 | testTrunc(-100, {toString: function() { return "-100.3"; }}); |
| 90 | testTrunc(10, {toString: function() { return 10.1; }}); |
| 91 | testTrunc(-1, {valueOf: function() { return -1.1; }}); |
| 92 | testTrunc(-Infinity, -Infinity); |
| 93 | testTrunc(Infinity, Infinity); |
| 94 | testTrunc(-Infinity, "-Infinity"); |
| 95 | testTrunc(Infinity, "Infinity"); |
| 96 | |
| 97 | assertTrue(isNaN(Math.trunc("abc"))); |
| 98 | assertTrue(isNaN(Math.trunc({}))); |
| 99 | assertTrue(isNaN(Math.trunc([1, 1]))); |
| 100 | } |
| 101 | |
| 102 | // Test in a loop to cover the custom IC and GC-related issues. |
| 103 | for (var i = 0; i < 10; i++) { |
no test coverage detected
searching dependent graphs…