Espruino/tests/test_arrow_functions.js
2016-09-21 18:46:06 +01:00

20 lines
337 B
JavaScript

// right now, only simple arrow functions are supported
// so no (a)=>a type stuff
var pass = 0;
var tests = 0;
function t(a,b) {
tests++;
var r = a(1,2,3);
if (r==b) pass++;
else console.log(r,"!=",b);
}
t( (a)=>{return a*42;}, 42);
t( (a,b)=>{return a+b;}, 1+2);
t( (a,b,c)=>{return a+b+c;}, 1+2+3);
result = pass==tests;