v8/test/mjsunit/harmony/to-string.js
Leszek Swirski b164fe240b [cleanup] Remove ToString intrinsic
The ToString intrinsic isn't used anymore, since there is now a ToString
bytecode, so we can remove it.

Change-Id: I5ed121ae4d117660e1ee8a64a2b30e1fb054a886
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2848465
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74151}
2021-04-23 15:02:42 +00:00

42 lines
1.0 KiB
JavaScript

// Copyright 2015 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
assertEquals("1", %ToString(1));
assertEquals("0.5", %ToString(.5));
assertEquals("null", %ToString(null));
assertEquals("true", %ToString(true));
assertEquals("false", %ToString(false));
assertEquals("undefined", %ToString(undefined));
assertEquals("random text", %ToString("random text"));
assertThrows(function() { %ToString(Symbol.toPrimitive) }, TypeError);
var a = { toString: function() { return "xyz" }};
assertEquals("xyz", %ToString(a));
var b = { valueOf: function() { return 42 }};
assertEquals("[object Object]", %ToString(b));
var c = {
toString: function() { return "x"},
valueOf: function() { return 123 }
};
assertEquals("x", %ToString(c));
var d = {
[Symbol.toPrimitive]: function(hint) { return hint }
};
assertEquals("string", %ToString(d));
var e = new Date(0);
assertEquals(e.toString(), %ToString(e));