blob: 9dc7c93a5538f7f257a1299b68b769b5d18a7060 [file] [log] [blame]
function shouldBe(actual, expected) {
if (actual !== expected)
throw new Error('bad value: ' + actual);
}
async function fn() {
// Both should have same structure.
const valueOfModule = await import('./resources/value-of-module.js');
const toStringModule = await import('./resources/to-string-module.js');
// These valueOf / toString should not be cached.
shouldBe(String(toStringModule), `2020`);
shouldBe(Number(toStringModule), 2020); // valueOf should not be cached since namespace object is impure for absent.
shouldBe(Number(valueOfModule), 42); // If the above access accidentally cached the value, this will not return 42.
shouldBe(String(valueOfModule), `42`);
}
fn().catch($vm.abort);