blob: ad3924b389db0b7891db5e8d2749770cc9dfd22b [file] [edit]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error("got " + actual + ", expected " + expected);
}
function shouldThrow(func, errorType) {
let threw = null;
try { func(); } catch (e) { threw = e; }
if (!threw || threw.constructor !== errorType)
throw new Error("expected " + errorType.name + ", got " + threw);
}
function f(a, n) { a.length = n; }
noInline(f);
for (let i = 0; i < testLoopCount; ++i) {
let a = [1, 2, 3, 4, 5];
let count = 0;
let obj = { valueOf() { count++; return 2; } };
f(a, obj);
shouldBe(a.length, 2);
shouldBe(count, 2);
}