| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Test non-primitive values and watch for valueOf call order. | 76 // Test non-primitive values and watch for valueOf call order. |
| 77 function TestNonPrimitive(order, f) { | 77 function TestNonPrimitive(order, f) { |
| 78 var result = ""; | 78 var result = ""; |
| 79 var x = { valueOf: function() { result += "x"; } }; | 79 var x = { valueOf: function() { result += "x"; } }; |
| 80 var y = { valueOf: function() { result += "y"; } }; | 80 var y = { valueOf: function() { result += "y"; } }; |
| 81 f(x, y); | 81 f(x, y); |
| 82 assertEquals(order, result); | 82 assertEquals(order, result); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TestNonPrimitive("xy", MaxLT); | 85 TestNonPrimitive("xy", MaxLT); |
| 86 TestNonPrimitive("yx", MaxLE); | 86 TestNonPrimitive("xy", MaxLE); |
| 87 TestNonPrimitive("xy", MaxGE); | 87 TestNonPrimitive("xy", MaxGE); |
| 88 TestNonPrimitive("yx", MaxGT); | 88 TestNonPrimitive("xy", MaxGT); |
| 89 | 89 |
| 90 // Test compare in case of aliased registers. | 90 // Test compare in case of aliased registers. |
| 91 function CmpX(x) { if (x == x) return 42; } | 91 function CmpX(x) { if (x == x) return 42; } |
| 92 assertEquals(42, CmpX(0)); | 92 assertEquals(42, CmpX(0)); |
| 93 | 93 |
| 94 function CmpXY(x) { var y = x; if (x == y) return 42; } | 94 function CmpXY(x) { var y = x; if (x == y) return 42; } |
| 95 assertEquals(42, CmpXY(0)); | 95 assertEquals(42, CmpXY(0)); |
| 96 | 96 |
| 97 | 97 |
| 98 // Test compare against null. | 98 // Test compare against null. |
| 99 function CmpNullValue(x) { return x == null; } | 99 function CmpNullValue(x) { return x == null; } |
| 100 assertEquals(false, CmpNullValue(42)); | 100 assertEquals(false, CmpNullValue(42)); |
| 101 | 101 |
| 102 function CmpNullTest(x) { if (x == null) return 42; return 0; } | 102 function CmpNullTest(x) { if (x == null) return 42; return 0; } |
| 103 assertEquals(42, CmpNullTest(null)); | 103 assertEquals(42, CmpNullTest(null)); |
| 104 | 104 |
| 105 var g1 = 0; | 105 var g1 = 0; |
| 106 function CmpNullEffect() { (g1 = 42) == null; } | 106 function CmpNullEffect() { (g1 = 42) == null; } |
| 107 CmpNullEffect(); | 107 CmpNullEffect(); |
| 108 assertEquals(42, g1); | 108 assertEquals(42, g1); |
| OLD | NEW |