Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: test/mjsunit/asm/math-abs.js

Issue 605123004: Extend JSBuiltinReducer to cover Math.abs as well. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-builtin-reducer-unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 abs = stdlib.Math.abs;
9
10 // f: double -> double
11 function f(a) {
12 a = +a;
13 return abs(a);
14 }
titzer 2014/09/26 13:35:13 How about an int32 and uint32 case too?
Michael Starzinger 2014/09/26 13:59:39 Done.
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("Infinity", String(1/f(0)));
26 assertEquals("Infinity", String(1/f(-0)));
27 assertEquals("Infinity", String(f(Infinity)));
28 assertEquals("Infinity", String(f(-Infinity)));
29
30 assertEquals(0, f(0));
31 assertEquals(0.1, f(0.1));
32 assertEquals(0.5, f(0.5));
33 assertEquals(0.1, f(-0.1));
34 assertEquals(0.5, f(-0.5));
35 assertEquals(1, f(1));
36 assertEquals(1.1, f(1.1));
37 assertEquals(1.5, f(1.5));
38 assertEquals(1, f(-1));
39 assertEquals(1.1, f(-1.1));
40 assertEquals(1.5, f(-1.5));
41
42 assertEquals(Number.MIN_VALUE, f(Number.MIN_VALUE));
43 assertEquals(Number.MIN_VALUE, f(-Number.MIN_VALUE));
44 assertEquals(Number.MAX_VALUE, f(Number.MAX_VALUE));
45 assertEquals(Number.MAX_VALUE, f(-Number.MAX_VALUE));
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698