blob: 3d82f816995e205d09e3f4332a30627fd19ae544 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
function test(array)
{
return array.slice(0);
}
noInline(test);
for (var i = 0; i < 1e5; ++i) {
var array = [i, i, i];
var result = test(array);
shouldBe(array !== result, true);
shouldBe(result.length, 3);
for (var j = 0; j < 3; ++j)
shouldBe(result[j], i);
}
function test2(array, i)
{
return array.slice(0, i);
}
noInline(test2);
for (var i = 0; i < 1e5; ++i) {
var array = [i, i, i];
var result = test2(array, 2);
shouldBe(array !== result, true);
shouldBe(result.length, 2);
for (var j = 0; j < 2; ++j)
shouldBe(result[j], i);
}