| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 assertTrue(v == v); | 221 assertTrue(v == v); |
| 222 assertTrue(v === v); | 222 assertTrue(v === v); |
| 223 assertTrue(v <= v); | 223 assertTrue(v <= v); |
| 224 assertTrue(v >= v); | 224 assertTrue(v >= v); |
| 225 assertFalse(v < v); | 225 assertFalse(v < v); |
| 226 assertFalse(v > v); | 226 assertFalse(v > v); |
| 227 assertFalse(v != v); | 227 assertFalse(v != v); |
| 228 assertFalse(v !== v); | 228 assertFalse(v !== v); |
| 229 | 229 |
| 230 // Right hand side of unary minus is overwritable. | 230 // Right hand side of unary minus is overwritable. |
| 231 v = 1.5 | 231 v = 1.5; |
| 232 assertEquals(-2.25, -(v * v)); | 232 assertEquals(-2.25, -(v * v)); |
| 233 | 233 |
| 234 // Smi input to bitop gives non-smi result where the rhs is a float that | 234 // Smi input to bitop gives non-smi result where the rhs is a float that |
| 235 // can be overwritten. | 235 // can be overwritten. |
| 236 var x1 = 0x10000000; | 236 var x1 = 0x10000000; |
| 237 var x2 = 0x40000002; | 237 var x2 = 0x40000002; |
| 238 var x3 = 0x40000000; | 238 var x3 = 0x40000000; |
| 239 assertEquals(0x40000000, x1 << (x2 - x3), "0x10000000<<1(1)"); | 239 assertEquals(0x40000000, x1 << (x2 - x3), "0x10000000<<1(1)"); |
| 240 | 240 |
| 241 // Smi input to bitop gives non-smi result where the rhs could be overwritten | 241 // Smi input to bitop gives non-smi result where the rhs could be overwritten |
| 242 // if it were a float, but it isn't. | 242 // if it were a float, but it isn't. |
| 243 x1 = 0x10000000 | 243 x1 = 0x10000000; |
| 244 x2 = 4 | 244 x2 = 4; |
| 245 x3 = 2 | 245 x3 = 2; |
| 246 assertEquals(0x40000000, x1 << (x2 - x3), "0x10000000<<2(2)"); | 246 assertEquals(0x40000000, x1 << (x2 - x3), "0x10000000<<2(2)"); |
| 247 | 247 |
| 248 | 248 |
| 249 // Test shift operators on non-smi inputs, giving smi and non-smi results. | 249 // Test shift operators on non-smi inputs, giving smi and non-smi results. |
| 250 function testShiftNonSmis() { | 250 function testShiftNonSmis() { |
| 251 var pos_non_smi = 2000000000; | 251 var pos_non_smi = 2000000000; |
| 252 var neg_non_smi = -pos_non_smi; | 252 var neg_non_smi = -pos_non_smi; |
| 253 var pos_smi = 1000000000; | 253 var pos_smi = 1000000000; |
| 254 var neg_smi = -pos_smi; | 254 var neg_smi = -pos_smi; |
| 255 | 255 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 } | 664 } |
| 665 } | 665 } |
| 666 | 666 |
| 667 intConversion(); | 667 intConversion(); |
| 668 | 668 |
| 669 // Verify that we handle the (optimized) corner case of shifting by | 669 // Verify that we handle the (optimized) corner case of shifting by |
| 670 // zero even for non-smis. | 670 // zero even for non-smis. |
| 671 function shiftByZero(n) { return n << 0; } | 671 function shiftByZero(n) { return n << 0; } |
| 672 | 672 |
| 673 assertEquals(3, shiftByZero(3.1415)); | 673 assertEquals(3, shiftByZero(3.1415)); |
| OLD | NEW |