Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7539681
test_function_constructor_tostring.cjs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
741 B
Referenced Files
None
Subscribers
None
test_function_constructor_tostring.cjs
View Options
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
Details
Attached
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)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment