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

Side by Side Diff: test/mjsunit/compiler/number-issafeinteger.js

Issue 2313073002: [builtins] Migrate Number predicates and make them optimizable. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 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: --allow-natives-syntax
6
7 function test(f) {
8 assertTrue(f(0));
9 assertTrue(f(Number.MIN_SAFE_INTEGER));
10 assertFalse(f(Number.MIN_SAFE_INTEGER - 13));
11 assertTrue(f(Number.MIN_SAFE_INTEGER + 13));
12 assertTrue(f(Number.MAX_SAFE_INTEGER));
13 assertFalse(f(Number.MAX_SAFE_INTEGER + 23));
14 assertTrue(f(Number.MAX_SAFE_INTEGER - 23));
15 assertFalse(f(Number.MIN_VALUE));
16 assertFalse(f(Number.MAX_VALUE));
17 assertFalse(f(Number.NaN));
18 assertFalse(f(Number.POSITIVE_INFINITY));
19 assertFalse(f(Number.NEGATIVE_INFINITY));
20 assertFalse(f(1 / 0));
21 assertFalse(f(-1 / 0));
22 assertFalse(f(Number.EPSILON));
23
24 var near_upper = Math.pow(2, 52);
25 assertTrue(f(near_upper));
26 assertFalse(f(2 * near_upper));
27 assertTrue(f(2 * near_upper - 1));
28 assertTrue(f(2 * near_upper - 2));
29 assertFalse(f(2 * near_upper + 1));
30 assertFalse(f(2 * near_upper + 2));
31 assertFalse(f(2 * near_upper + 7));
32
33 var near_lower = -near_upper;
34 assertTrue(f(near_lower));
35 assertFalse(f(2 * near_lower));
36 assertTrue(f(2 * near_lower + 1));
37 assertTrue(f(2 * near_lower + 2));
38 assertFalse(f(2 * near_lower - 1));
39 assertFalse(f(2 * near_lower - 2));
40 assertFalse(f(2 * near_lower - 7));
41 }
42
43 function f(x) {
44 return Number.isSafeInteger(+x);
45 }
46
47 test(f);
48 test(f);
49 %OptimizeFunctionOnNextCall(f);
50 test(f);
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/number-isnan.js ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698