summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/constant-fold-tostring.js
blob: e9c6d916cecdc6d01d6a90457e902b4dac5502e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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 --no-always-opt --opt

// Check that constant-folding of ToString operations works properly for NaN.
(function() {
  const foo = () => `${NaN}`;
  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}`;
  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));
})();