OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010, 2011 the V8 project authors. All rights reserved. |
Kevin Millikin (Chromium)
2011/08/02 10:24:14
We just update the copyright date to 2011, not a r
| |
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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 25 matching lines...) Expand all Loading... | |
37 %OptimizeFunctionOnNextCall(doRound); | 37 %OptimizeFunctionOnNextCall(doRound); |
38 assertEquals(expect, doRound(input)); | 38 assertEquals(expect, doRound(input)); |
39 } | 39 } |
40 | 40 |
41 testRound(0, 0); | 41 testRound(0, 0); |
42 testRound(-0, -0); | 42 testRound(-0, -0); |
43 testRound(Infinity, Infinity); | 43 testRound(Infinity, Infinity); |
44 testRound(-Infinity, -Infinity); | 44 testRound(-Infinity, -Infinity); |
45 testRound(NaN, NaN); | 45 testRound(NaN, NaN); |
46 | 46 |
47 // Ensure that a negative zero coming from Math.round is properly | |
48 // handled by other ops that take unboxed doubles. See cr7514040. | |
49 function roundsum(i,n) { | |
50 var ret = Math.round(n); | |
51 while (--i > 0) { | |
52 ret += Math.round(n); | |
53 } | |
54 return ret; | |
55 } | |
56 assertEquals(-0, roundsum(1000,-0)); | |
57 %OptimizeFunctionOnNextCall(roundsum); | |
58 // It seems that %OptimizeFunctionOnNextCall doesn't always work! Here | |
59 // we push iterations up to a large number to ensure that we try to | |
60 // unbox doubles as much as possible. | |
61 assertEquals(-0, roundsum(1000000,-0)); | |
62 | |
47 testRound(1, 0.5); | 63 testRound(1, 0.5); |
48 testRound(1, 0.7); | 64 testRound(1, 0.7); |
49 testRound(1, 1); | 65 testRound(1, 1); |
50 testRound(1, 1.1); | 66 testRound(1, 1.1); |
51 testRound(1, 1.49999); | 67 testRound(1, 1.49999); |
52 testRound(-0, -0.5); | 68 testRound(-0, -0.5); |
53 testRound(-1, -0.5000000000000001); | 69 testRound(-1, -0.5000000000000001); |
54 testRound(-1, -0.7); | 70 testRound(-1, -0.7); |
55 testRound(-1, -1); | 71 testRound(-1, -1); |
56 testRound(-1, -1.1); | 72 testRound(-1, -1.1); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 testRound(-Math.pow(2,52)+1, -max_fraction); | 164 testRound(-Math.pow(2,52)+1, -max_fraction); |
149 testRound(-min_nonfraction, -min_nonfraction); | 165 testRound(-min_nonfraction, -min_nonfraction); |
150 testRound(-max_non_infinite, -max_non_infinite); | 166 testRound(-max_non_infinite, -max_non_infinite); |
151 | 167 |
152 testRound(min_smi31, min_smi31 - 0.5); | 168 testRound(min_smi31, min_smi31 - 0.5); |
153 testRound(min_smi31 + 1, min_smi31 + 0.5); | 169 testRound(min_smi31 + 1, min_smi31 + 0.5); |
154 testRound(min_smi32, min_smi32 - 0.5); | 170 testRound(min_smi32, min_smi32 - 0.5); |
155 testRound(min_smi32 + 1, min_smi32 + 0.5); | 171 testRound(min_smi32 + 1, min_smi32 + 0.5); |
156 | 172 |
157 | 173 |
OLD | NEW |