diff --git a/set.js b/set.js index 8070fd4..fd8e1a0 100644 --- a/set.js +++ b/set.js @@ -43,6 +43,7 @@ var value = true } var Set = function(input){ + if (!(this instanceof Set)) return new Set(input) this._set = unique(input || []) } diff --git a/test/set-test.js b/test/set-test.js index aaf30e0..ee1c103 100644 --- a/test/set-test.js +++ b/test/set-test.js @@ -195,5 +195,21 @@ vows.describe('Set').addBatch({ } } } + + , "Initialized with [0,1,2,3,4] without the new keyword": { + topic: Set([0, 1, 2, 3, 4]) + + , "will be a Set": function(topic){ + assert.instanceOf(topic, Set) + } + + , "is not empty": function(topic){ + assert.isFalse(topic.empty()) + } + + , "contains a 0": function(topic){ + assert.isTrue(topic.contains(0)) + } + } } }).export(module)