OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 24 matching lines...) Expand all Loading... |
35 assertEquals(1, Math.min(2, 1)); | 35 assertEquals(1, Math.min(2, 1)); |
36 assertEquals(1, Math.min(1, 2, 3)); | 36 assertEquals(1, Math.min(1, 2, 3)); |
37 assertEquals(1, Math.min(3, 2, 1)); | 37 assertEquals(1, Math.min(3, 2, 1)); |
38 assertEquals(1, Math.min(2, 3, 1)); | 38 assertEquals(1, Math.min(2, 3, 1)); |
39 assertEquals(1.1, Math.min(1.1, 2.2, 3.3)); | 39 assertEquals(1.1, Math.min(1.1, 2.2, 3.3)); |
40 assertEquals(1.1, Math.min(3.3, 2.2, 1.1)); | 40 assertEquals(1.1, Math.min(3.3, 2.2, 1.1)); |
41 assertEquals(1.1, Math.min(2.2, 3.3, 1.1)); | 41 assertEquals(1.1, Math.min(2.2, 3.3, 1.1)); |
42 | 42 |
43 // Prepare a non-Smi zero value. | 43 // Prepare a non-Smi zero value. |
44 function returnsNonSmi(){ return 0.25; } | 44 function returnsNonSmi(){ return 0.25; } |
45 var ZERO = returnsNonSmi() - returnsNonSmi(); | 45 var ZERO = (function() { |
| 46 var z; |
| 47 // We have to have a loop here because the first time we get a Smi from the |
| 48 // runtime system. After a while the binary op IC settles down and we get |
| 49 // a non-Smi from the generated code. |
| 50 for (var i = 0; i < 10; i++) { |
| 51 z = returnsNonSmi() - returnsNonSmi(); |
| 52 } |
| 53 return z; |
| 54 })(); |
46 assertEquals(0, ZERO); | 55 assertEquals(0, ZERO); |
47 assertEquals(Infinity, 1/ZERO); | 56 assertEquals(Infinity, 1/ZERO); |
48 assertEquals(-Infinity, 1/-ZERO); | 57 assertEquals(-Infinity, 1/-ZERO); |
49 assertFalse(%_IsSmi(ZERO)); | 58 assertFalse(%_IsSmi(ZERO)); |
50 assertFalse(%_IsSmi(-ZERO)); | 59 assertFalse(%_IsSmi(-ZERO)); |
51 | 60 |
52 var o = {}; | 61 var o = {}; |
53 o.valueOf = function() { return 1; }; | 62 o.valueOf = function() { return 1; }; |
54 assertEquals(1, Math.min(2, 3, '1')); | 63 assertEquals(1, Math.min(2, 3, '1')); |
55 assertEquals(1, Math.min(3, o, 2)); | 64 assertEquals(1, Math.min(3, o, 2)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 assertEquals(1, Math.max(+0, -0, +1)); | 105 assertEquals(1, Math.max(+0, -0, +1)); |
97 assertEquals(1, Math.max(+1, +0, -0)); | 106 assertEquals(1, Math.max(+1, +0, -0)); |
98 assertEquals(1, Math.max(+0, +1, -0)); | 107 assertEquals(1, Math.max(+0, +1, -0)); |
99 assertEquals(1, Math.max(-0, +1, +0)); | 108 assertEquals(1, Math.max(-0, +1, +0)); |
100 assertNaN(Math.max('oxen')); | 109 assertNaN(Math.max('oxen')); |
101 assertNaN(Math.max('oxen', 1)); | 110 assertNaN(Math.max('oxen', 1)); |
102 assertNaN(Math.max(1, 'oxen')); | 111 assertNaN(Math.max(1, 'oxen')); |
103 | 112 |
104 assertEquals(Infinity, 1/Math.max(ZERO, -0)); | 113 assertEquals(Infinity, 1/Math.max(ZERO, -0)); |
105 assertEquals(Infinity, 1/Math.max(-0, ZERO)); | 114 assertEquals(Infinity, 1/Math.max(-0, ZERO)); |
OLD | NEW |