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 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --allow-natives-syntax | 28 // Flags: --allow-natives-syntax |
29 | 29 |
30 function testRound(expect, input) { | 30 function testRound(expect, input) { |
31 function doRound(input) { | 31 function doRound(input) { |
32 return Math.round(input); | 32 return Math.round(input); |
33 } | 33 } |
34 assertEquals(expect, doRound(input)); | 34 assertEquals(expect, doRound(input)); |
| 35 assertEquals(expect, doRound(input)); |
| 36 assertEquals(expect, doRound(input)); |
35 %OptimizeFunctionOnNextCall(doRound); | 37 %OptimizeFunctionOnNextCall(doRound); |
36 assertEquals(expect, doRound(input)); | 38 assertEquals(expect, doRound(input)); |
37 } | 39 } |
38 | 40 |
39 testRound(0, 0); | 41 testRound(0, 0); |
40 testRound(-0, -0); | 42 testRound(-0, -0); |
41 testRound(Infinity, Infinity); | 43 testRound(Infinity, Infinity); |
42 testRound(-Infinity, -Infinity); | 44 testRound(-Infinity, -Infinity); |
43 testRound(NaN, NaN); | 45 testRound(NaN, NaN); |
44 | 46 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 testRound(-Math.pow(2,52)+1, -max_fraction); | 148 testRound(-Math.pow(2,52)+1, -max_fraction); |
147 testRound(-min_nonfraction, -min_nonfraction); | 149 testRound(-min_nonfraction, -min_nonfraction); |
148 testRound(-max_non_infinite, -max_non_infinite); | 150 testRound(-max_non_infinite, -max_non_infinite); |
149 | 151 |
150 testRound(min_smi31, min_smi31 - 0.5); | 152 testRound(min_smi31, min_smi31 - 0.5); |
151 testRound(min_smi31 + 1, min_smi31 + 0.5); | 153 testRound(min_smi31 + 1, min_smi31 + 0.5); |
152 testRound(min_smi32, min_smi32 - 0.5); | 154 testRound(min_smi32, min_smi32 - 0.5); |
153 testRound(min_smi32 + 1, min_smi32 + 0.5); | 155 testRound(min_smi32 + 1, min_smi32 + 0.5); |
154 | 156 |
155 | 157 |
OLD | NEW |