2017-09-12 12:25:44 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-04-28 14:22:23 +00:00
|
|
|
// Flags: --allow-natives-syntax --no-always-turbofan --turbofan
|
2017-09-12 12:25:44 +00:00
|
|
|
|
|
|
|
// Check that constant-folding of ToString operations works properly for NaN.
|
|
|
|
(function() {
|
|
|
|
const foo = () => `${NaN}`;
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-09-12 12:25:44 +00:00
|
|
|
assertEquals("NaN", foo());
|
|
|
|
assertEquals("NaN", foo());
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertEquals("NaN", foo());
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Check that constant-folding of ToString operations works properly for 0/-0.
|
|
|
|
(function() {
|
|
|
|
const foo = x => `${x ? 0 : -0}`;
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-09-12 12:25:44 +00:00
|
|
|
assertEquals("0", foo(true));
|
|
|
|
assertEquals("0", foo(false));
|
|
|
|
assertEquals("0", foo(true));
|
|
|
|
assertEquals("0", foo(false));
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertEquals("0", foo(true));
|
|
|
|
assertEquals("0", foo(false));
|
|
|
|
})();
|