31a3cfbc10
BUG=v8:8801 Change-Id: I9d9d9824c6c9ad0176bbfd3723da1b578b17c256 Reviewed-on: https://chromium-review.googlesource.com/c/1495555 Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Cr-Commit-Position: refs/heads/master@{#60001}
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
// Ensure that the typing rule for Math.trunc deals correctly with
|
|
// inputs in the range (-1.0,0.0), which are mapped to -0.
|
|
(function() {
|
|
function foo(x) {
|
|
// Arrange x such that TurboFan infers type PlainNumber \/ NaN.
|
|
x = +x;
|
|
x = Math.abs(x) - 1.0;
|
|
return Object.is(-0, Math.trunc(x));
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertFalse(foo(1.5));
|
|
assertTrue(foo(0.5));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertFalse(foo(1.5));
|
|
assertTrue(foo(0.5));
|
|
})();
|
|
|
|
// Ensure that the typing rule for Math.trunc deals correctly with
|
|
// NaN inputs, which are mapped to NaN.
|
|
(function() {
|
|
function foo(x) {
|
|
// Arrange x such that TurboFan infers type PlainNumber \/ NaN.
|
|
x = +x;
|
|
x = Math.abs(x) - 1.0;
|
|
return Object.is(NaN, Math.trunc(x));
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertFalse(foo(1.5));
|
|
assertTrue(foo(NaN));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertFalse(foo(1.5));
|
|
assertTrue(foo(NaN));
|
|
})();
|