Serenity Operating System
at hosted 17 lines 492 B view raw
1// Borrowed from LibM/TestMath.cpp :^) 2function expectClose(a, b) { assert(Math.abs(a - b) < 0.000001); } 3 4try { 5 expectClose(Math.E, 2.718281); 6 expectClose(Math.LN2, 0.693147); 7 expectClose(Math.LN10, 2.302585); 8 expectClose(Math.LOG2E, 1.442695); 9 expectClose(Math.LOG10E, 0.434294); 10 expectClose(Math.PI, 3.1415926); 11 expectClose(Math.SQRT1_2, 0.707106); 12 expectClose(Math.SQRT2, 1.414213); 13 14 console.log("PASS"); 15} catch (e) { 16 console.log("FAIL: " + e); 17}