blob: 6a95327523c9124bf22b54202b051aa5fc196ca5 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}
var func = Map.prototype.set;
function target(map)
{
return func.call(map, 42, 42);
}
noInline(target);
for (var i = 0; i < 1e6; ++i) {
var map = new Map();
shouldBe(target(map), map);
shouldBe(map.get(42), 42);
}
shouldThrow(() => {
target(new Set());
}, `TypeError: Map operation called on non-Map object`);