Page MenuHomePhorge

test_function_constructor_tostring.cjs
No OneTemporary

Size
741 B
Referenced Files
None
Subscribers
None

test_function_constructor_tostring.cjs

let failed = 0;
const bodyObj = {
toString() {
return "return x + 41;";
},
};
const paramObj = {
toString() {
return "x";
},
};
try {
const fn = Function(paramObj, bodyObj);
if (fn(1) !== 42) {
failed++;
console.log("direct Function() returned wrong value");
}
} catch (e) {
failed++;
console.log("direct Function() threw:", e && e.message ? e.message : e);
}
try {
const fn2 = Function.apply(null, [paramObj, bodyObj]);
if (fn2(2) !== 43) {
failed++;
console.log("Function.apply() returned wrong value");
}
} catch (e) {
failed++;
console.log("Function.apply() threw:", e && e.message ? e.message : e);
}
if (failed > 0) throw new Error("test_function_constructor_tostring failed");

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 17, 1:27 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557224
Default Alt Text
test_function_constructor_tostring.cjs (741 B)

Event Timeline