MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 37 lines 741 B view raw
1let failed = 0; 2 3const bodyObj = { 4 toString() { 5 return "return x + 41;"; 6 }, 7}; 8 9const paramObj = { 10 toString() { 11 return "x"; 12 }, 13}; 14 15try { 16 const fn = Function(paramObj, bodyObj); 17 if (fn(1) !== 42) { 18 failed++; 19 console.log("direct Function() returned wrong value"); 20 } 21} catch (e) { 22 failed++; 23 console.log("direct Function() threw:", e && e.message ? e.message : e); 24} 25 26try { 27 const fn2 = Function.apply(null, [paramObj, bodyObj]); 28 if (fn2(2) !== 43) { 29 failed++; 30 console.log("Function.apply() returned wrong value"); 31 } 32} catch (e) { 33 failed++; 34 console.log("Function.apply() threw:", e && e.message ? e.message : e); 35} 36 37if (failed > 0) throw new Error("test_function_constructor_tostring failed");