863a2d6c24
This also removes intrinsics that were just used in tests. It keeps InlineIncBlockCounter for now because it's a less straightforward. Change-Id: I77e55d7a746294892d0fd7ab577ebf8eb42f1f08 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2953195 Commit-Queue: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#75217}
57 lines
1.3 KiB
JavaScript
57 lines
1.3 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(0, %ToLength(NaN));
|
|
|
|
assertEquals(0, %ToLength(-Infinity));
|
|
|
|
assertEquals(0, %ToLength(0));
|
|
|
|
assertEquals(0, %ToLength(.5));
|
|
|
|
assertEquals(42, %ToLength(42.99999));
|
|
|
|
assertEquals(9007199254740991, %ToLength(9007199254740991));
|
|
|
|
assertEquals(9007199254740991, %ToLength(Infinity));
|
|
|
|
assertEquals(0, %ToLength(null));
|
|
|
|
assertEquals(1, %ToLength(true));
|
|
|
|
assertEquals(0, %ToLength(false));
|
|
|
|
assertEquals(0, %ToLength(undefined));
|
|
|
|
assertEquals(0, %ToLength("-1"));
|
|
assertEquals(123, %ToLength("123"));
|
|
assertEquals(0, %ToLength("random text"));
|
|
|
|
assertThrows(function() { %ToLength(Symbol.toPrimitive) }, TypeError);
|
|
|
|
var a = { toString: function() { return 54321 }};
|
|
assertEquals(54321, %ToLength(a));
|
|
|
|
var b = { valueOf: function() { return 42 }};
|
|
assertEquals(42, %ToLength(b));
|
|
|
|
var c = {
|
|
toString: function() { return "x"},
|
|
valueOf: function() { return 123 }
|
|
};
|
|
assertEquals(123, %ToLength(c));
|
|
|
|
var d = {
|
|
[Symbol.toPrimitive]: function(hint) {
|
|
assertEquals("number", hint);
|
|
return 987654321;
|
|
}
|
|
};
|
|
assertEquals(987654321, %ToLength(d));
|
|
|
|
var e = new Date(0);
|
|
assertEquals(0, %ToLength(e));
|