From 7805a508828e93d2bd9a710c939fa96932c577e2 Mon Sep 17 00:00:00 2001 From: Denis Bardadym Date: Thu, 26 Dec 2013 12:17:05 +0400 Subject: [PATCH] Add possibility to use instanceof with primitive types, by wrapping it with Object function --- test/should.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/should.test.js b/test/should.test.js index 3614b22..df7b1ec 100644 --- a/test/should.test.js +++ b/test/should.test.js @@ -177,6 +177,14 @@ module.exports = { (number instanceof Number).should.be.true; number.should.be.an.instanceof(Number); + var boolean = Object(true); + (boolean instanceof Boolean).should.be.true; + boolean.should.be.an.instanceof(Boolean); + + var string = Object('string'); + (string instanceof String).should.be.true; + string.should.be.an.instanceof(String); + err(function(){ (3).should.an.instanceof(Foo); }, "expected 3 to be an instance of Foo");