/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/test/mjsunit/compiler/math-round.js
41 строка
1 KB
Ujjwal Sharma
deps: update V8 to 7.4.288.13
28 мар 2019, 23:36
28 мар 2019, 23:36
f579e11
Код
Авторство
О чём код?
// 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.round deals correctly with // inputs in the range [-0.5,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.round(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.round 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.round(x)); } %PrepareFunctionForOptimization(foo); assertFalse(foo(1.5)); assertTrue(foo(NaN)); %OptimizeFunctionOnNextCall(foo); assertFalse(foo(1.5)); assertTrue(foo(NaN)); })();