OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-maths | |
6 | |
7 // Monkey-patch Float32Array. | 5 // Monkey-patch Float32Array. |
8 Float32Array = function(x) { this[0] = 0; }; | 6 Float32Array = function(x) { this[0] = 0; }; |
9 | 7 |
10 assertTrue(isNaN(Math.fround(NaN))); | 8 assertTrue(isNaN(Math.fround(NaN))); |
11 assertTrue(isNaN(Math.fround(function() {}))); | 9 assertTrue(isNaN(Math.fround(function() {}))); |
12 assertTrue(isNaN(Math.fround({ toString: function() { return NaN; } }))); | 10 assertTrue(isNaN(Math.fround({ toString: function() { return NaN; } }))); |
13 assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } }))); | 11 assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } }))); |
14 assertEquals("Infinity", String(1/Math.fround(0))); | 12 assertEquals("Infinity", String(1/Math.fround(0))); |
15 assertEquals("-Infinity", String(1/Math.fround(-0))); | 13 assertEquals("-Infinity", String(1/Math.fround(-0))); |
16 assertEquals("Infinity", String(Math.fround(Infinity))); | 14 assertEquals("Infinity", String(Math.fround(Infinity))); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 assertEquals(float.toSingle(), Math.fround(float.toDouble())); | 88 assertEquals(float.toSingle(), Math.fround(float.toDouble())); |
91 } | 89 } |
92 } | 90 } |
93 } | 91 } |
94 | 92 |
95 for (var sign = 0; sign < 2; sign++) { | 93 for (var sign = 0; sign < 2; sign++) { |
96 for (var exp = 1024 - 170; exp < 1024 + 170; exp++) { | 94 for (var exp = 1024 - 170; exp < 1024 + 170; exp++) { |
97 fuzz_mantissa(sign, exp, 1337 * exp - sign, 127913 * exp - sign); | 95 fuzz_mantissa(sign, exp, 1337 * exp - sign, 127913 * exp - sign); |
98 } | 96 } |
99 } | 97 } |
OLD | NEW |