From 4fb414159feb26452f2881f561f1759bc86dc60b Mon Sep 17 00:00:00 2001 From: "Hemanth.HM" Date: Fri, 14 Nov 2014 12:20:49 +0530 Subject: [PATCH] All RegExp checks. --- index.js | 5 +++++ test/enable.test.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/index.js b/index.js index 67010f2..f44cdac 100644 --- a/index.js +++ b/index.js @@ -108,3 +108,8 @@ exports.Math = { exports.Promise = typeof Promise !== 'undefined' && isFunction(Promise.all); +var RegExp = {'prototype' : {} }; +['match', 'replace', 'split', 'search'].forEach(function(regex){ + RegExp.prototype[regex] = isFunction(regex); +}); +exports.RegExp = RegExp; diff --git a/test/enable.test.js b/test/enable.test.js index 54701c1..6af71e2 100644 --- a/test/enable.test.js +++ b/test/enable.test.js @@ -398,4 +398,44 @@ describe('enable.test.js', function () { } }); + it("should detect RegExp.prototype.match", function(){ + enable.RegExp.prototype.match.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.RegExp.prototype.match.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.RegExp.prototype.match.should.equal(false); + } + }); + + it("should detect RegExp.prototype.replace", function(){ + enable.RegExp.prototype.replace.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.RegExp.prototype.replace.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.RegExp.prototype.replace.should.equal(false); + } + }); + + it("should detect RegExp.prototype.split", function(){ + enable.RegExp.prototype.split.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.RegExp.prototype.split.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.RegExp.prototype.split.should.equal(false); + } + }); + + it("should detect RegExp.prototype.search", function(){ + enable.RegExp.prototype.search.should.be.a.Boolean; + if (process.version.indexOf('v0.10.') === 0) { + enable.RegExp.prototype.search.should.equal(false); + } + if (process.version.indexOf('v0.11.') === 0) { + enable.RegExp.prototype.search.should.equal(false); + } + }); + });