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 function Module(stdlib) { |
| 6 "use asm"; |
| 7 |
| 8 var floor = stdlib.Math.floor; |
| 9 |
| 10 // f: double -> float |
| 11 function f(a) { |
| 12 a = +a; |
| 13 return floor(a); |
| 14 } |
| 15 |
| 16 return { f: f }; |
| 17 } |
| 18 |
| 19 var f = Module({ Math: Math }).f; |
| 20 |
| 21 assertTrue(isNaN(f(NaN))); |
| 22 assertTrue(isNaN(f(undefined))); |
| 23 assertTrue(isNaN(f(function() {}))); |
| 24 |
| 25 assertEquals(0, f(0)); |
| 26 assertEquals(+0, f(+0)); |
| 27 assertEquals(-0, f(-0)); |
| 28 assertEquals(0, f(0.49999)); |
| 29 assertEquals(+0, f(0.6)); |
| 30 assertEquals(+0, f(0.5)); |
| 31 assertEquals(-1, f(-0.1)); |
| 32 assertEquals(-1, f(-0.5)); |
| 33 assertEquals(-1, f(-0.6)); |
| 34 assertEquals(-2, f(-1.6)); |
| 35 assertEquals(-1, f(-0.50001)); |
| 36 |
| 37 assertEquals("Infinity", String(f(Infinity))); |
| 38 assertEquals("-Infinity", String(f(-Infinity))); |
OLD | NEW |