From 608e3233c295949d584828a2cc68f42309367d87 Mon Sep 17 00:00:00 2001 From: "Hemanth.HM" Date: Tue, 11 Nov 2014 15:55:10 +0530 Subject: [PATCH] All Math related method. --- index.js | 22 +++++- test/enable.test.js | 168 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 185 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index b65a723..ee8b87a 100644 --- a/index.js +++ b/index.js @@ -84,4 +84,24 @@ exports.Number = { EPSILON: isNumber(Number.EPSILON), MIN_SAFE_INTEGER: isNumber(Number.MIN_SAFE_INTEGER), MAX_SAFE_INTEGER: isNumber(Number.MAX_SAFE_INTEGER) -}; \ No newline at end of file +}; + +exports.Math = { + clz32: isFunction(Math.clz32), + imul: isFunction(Math.imul), + sign: isFunction(Math.sign), + log10: isFunction(Math.log10), + log2: isFunction(Math.log2), + log1p: isFunction(Math.log1p), + expm1: isFunction(Math.expm1), + cosh: isFunction(Math.cosh), + sinh: isFunction(Math.sinh), + tanh: isFunction(Math.tanh), + acosh: isFunction(Math.acosh), + asinh: isFunction(Math.asinh), + atanh: isFunction(Math.atanh), + hypot: isFunction(Math.hypot), + trunc: isFunction(Math.trunc), + fround: isFunction(Math.fround), + cbrt: isFunction(Math.cbrt) +} \ No newline at end of file diff --git a/test/enable.test.js b/test/enable.test.js index d4525ee..44a722d 100644 --- a/test/enable.test.js +++ b/test/enable.test.js @@ -217,13 +217,173 @@ describe('enable.test.js', function () { } }); - it("should detect Number.MAX_SAFE_INTEGER", function(){ - enable.Number.MAX_SAFE_INTEGER.should.be.a.Boolean; + it("should detect Math.clz32", function(){ + enable.Math.clz32.should.be.a.Boolean; if (process.version.indexOf('v0.10.') === 0) { - enable.Number.MAX_SAFE_INTEGER.should.equal(false); + enable.Math.clz32.should.equal(false); } if (process.version.indexOf('v0.11.') === 0) { - enable.Number.MAX_SAFE_INTEGER.should.equal(true); + enable.Math.clz32.should.equal(true); + } + }); + + it("should detect Math.imul", function(){ + enable.Math.imul.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.imul.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.imul.should.equal(true); + } + }); + + it("should detect Math.sign", function(){ + enable.Math.sign.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.sign.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.sign.should.equal(true); + } + }); + + it("should detect Math.log10", function(){ + enable.Math.log10.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.log10.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.log10.should.equal(true); + } + }); + + it("should detect Math.log2", function(){ + enable.Math.log2.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.log2.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.log2.should.equal(true); + } + }); + + it("should detect Math.log1p", function(){ + enable.Math.log1p.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.log1p.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.log1p.should.equal(true); + } + }); + + it("should detect Math.expm1", function(){ + enable.Math.expm1.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.expm1.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.expm1.should.equal(true); + } + }); + + it("should detect Math.cosh", function(){ + enable.Math.cosh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.cosh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.cosh.should.equal(true); + } + }); + + it("should detect Math.sinh", function(){ + enable.Math.sinh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.sinh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.sinh.should.equal(true); + } + }); + + it("should detect Math.tanh", function(){ + enable.Math.tanh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.tanh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.tanh.should.equal(true); + } + }); + + it("should detect Math.acosh", function(){ + enable.Math.acosh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.acosh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.acosh.should.equal(true); + } + }); + + it("should detect Math.asinh", function(){ + enable.Math.asinh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.asinh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.asinh.should.equal(true); + } + }); + + it("should detect Math.atanh", function(){ + enable.Math.atanh.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.atanh.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.atanh.should.equal(true); + } + }); + + it("should detect Math.hypot", function(){ + enable.Math.hypot.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.hypot.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.hypot.should.equal(true); + } + }); + + it("should detect Math.trunc", function(){ + enable.Math.trunc.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.trunc.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.trunc.should.equal(true); + } + }); + + it("should detect Math.fround", function(){ + enable.Math.fround.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.fround.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.fround.should.equal(true); + } + }); + + it("should detect Math.cbrt", function(){ + enable.Math.cbrt.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.Math.cbrt.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.Math.cbrt.should.equal(true); } });