mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 11:36:57 +00:00

PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
61 lines
1.4 KiB
JavaScript
61 lines
1.4 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
|
|
|
|
(function() {
|
|
function foo(x) { return Number.isNaN(x); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertTrue(foo(+undefined));
|
|
assertFalse(foo(undefined));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertTrue(foo(+undefined));
|
|
assertFalse(foo(undefined));
|
|
})();
|
|
|
|
(function() {
|
|
function foo(x) { return Number.isNaN(+x); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertTrue(foo(+undefined));
|
|
assertFalse(foo(0));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertTrue(foo(+undefined));
|
|
assertFalse(foo(0));
|
|
})();
|
|
|
|
(function() {
|
|
function foo(x) { return Number.isNaN(x|0); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertFalse(foo(+undefined));
|
|
assertFalse(foo(0));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertFalse(foo(+undefined));
|
|
assertFalse(foo(0));
|
|
})();
|
|
|
|
(function() {
|
|
function foo(x) { return Number.isNaN("" + x); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertFalse(foo(undefined));
|
|
assertFalse(foo(0));
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertFalse(foo(undefined));
|
|
assertFalse(foo(0));
|
|
})();
|
|
|
|
(function() {
|
|
function foo(x) { return Number.isNaN(0/0); }
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
assertTrue(foo());
|
|
assertTrue(foo());
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
assertTrue(foo());
|
|
assertTrue(foo());
|
|
})();
|