mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 02:54:19 +00:00

Pick up the latest branch head for V8 4.7:
be169f8df0
Full change history for the 4.7 branch:
https://chromium.googlesource.com/v8/v8.git/+log/branch-heads/4.7
V8 blog post about what is new on V8 4.7:
http://v8project.blogspot.de/2015/10/v8-release-47.html
PR-URL: https://github.com/nodejs/node/pull/4106
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: rvagg - Rod Vagg <rod@vagg.org>
55 lines
1.6 KiB
JavaScript
55 lines
1.6 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("1", %_ToString(1));
|
|
|
|
assertEquals("0.5", %ToString(.5));
|
|
assertEquals("0.5", %_ToString(.5));
|
|
|
|
assertEquals("null", %ToString(null));
|
|
assertEquals("null", %_ToString(null));
|
|
|
|
assertEquals("true", %ToString(true));
|
|
assertEquals("true", %_ToString(true));
|
|
|
|
assertEquals("false", %ToString(false));
|
|
assertEquals("false", %_ToString(false));
|
|
|
|
assertEquals("undefined", %ToString(undefined));
|
|
assertEquals("undefined", %_ToString(undefined));
|
|
|
|
assertEquals("random text", %ToString("random text"));
|
|
assertEquals("random text", %_ToString("random text"));
|
|
|
|
assertThrows(function() { %ToString(Symbol.toPrimitive) }, TypeError);
|
|
assertThrows(function() { %_ToString(Symbol.toPrimitive) }, TypeError);
|
|
|
|
var a = { toString: function() { return "xyz" }};
|
|
assertEquals("xyz", %ToString(a));
|
|
assertEquals("xyz", %_ToString(a));
|
|
|
|
var b = { valueOf: function() { return 42 }};
|
|
assertEquals("[object Object]", %ToString(b));
|
|
assertEquals("[object Object]", %_ToString(b));
|
|
|
|
var c = {
|
|
toString: function() { return "x"},
|
|
valueOf: function() { return 123 }
|
|
};
|
|
assertEquals("x", %ToString(c));
|
|
assertEquals("x", %_ToString(c));
|
|
|
|
var d = {
|
|
[Symbol.toPrimitive]: function(hint) { return hint }
|
|
};
|
|
assertEquals("string", %ToString(d));
|
|
assertEquals("string", %_ToString(d));
|
|
|
|
var e = new Date(0);
|
|
assertEquals(e.toString(), %ToName(e));
|
|
assertEquals(e.toString(), %_ToName(e));
|