OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --turbo-asm |
| 6 |
| 7 function Module(stdlib) { |
| 8 "use asm"; |
| 9 |
| 10 var fround = stdlib.Math.fround; |
| 11 |
| 12 // f: double -> float |
| 13 function f(a) { |
| 14 a = +a; |
| 15 return fround(a); |
| 16 } |
| 17 |
| 18 return { f: f }; |
| 19 } |
| 20 |
| 21 var f = Module({ Math: Math }).f; |
| 22 |
| 23 assertTrue(isNaN(f(NaN))); |
| 24 assertTrue(isNaN(f(undefined))); |
| 25 assertTrue(isNaN(f(function() {}))); |
| 26 |
| 27 assertEquals("Infinity", String(1/f(0))); |
| 28 assertEquals("-Infinity", String(1/f(-0))); |
| 29 assertEquals("Infinity", String(f(Infinity))); |
| 30 assertEquals("-Infinity", String(f(-Infinity))); |
| 31 assertEquals("Infinity", String(f(1E200))); |
| 32 assertEquals("-Infinity", String(f(-1E200))); |
| 33 assertEquals("Infinity", String(1/f(1E-300))); |
| 34 assertEquals("-Infinity", String(1/f(-1E-300))); |
| 35 |
| 36 assertEquals(0, f(0)); |
| 37 assertEquals(1, f(1)); |
| 38 assertEquals(1.5, f(1.5)); |
| 39 assertEquals(1.3370000123977661, f(1.337)); |
| 40 assertEquals(-4.300000190734863, f(-4.3)); |
OLD | NEW |