binary-search-tree
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -205,3 +205,6 @@ /** | ||
if (this.unique) { | ||
throw "Can't insert key " + key + ", it violates the unique constraint"; | ||
throw { message: "Can't insert key " + key + ", it violates the unique constraint" | ||
, key: key | ||
, errorType: 'uniqueViolated' | ||
}; | ||
} else { | ||
@@ -208,0 +211,0 @@ this.data.push(value); |
{ | ||
"name": "binary-search-tree", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Louis Chatriot", |
@@ -301,3 +301,8 @@ var should = require('chai').should() | ||
bst.insert(3, 'hello'); | ||
(function () { bst.insert(3, 'world'); }).should.throw(); | ||
try { | ||
bst.insert(3, 'world'); | ||
} catch (e) { | ||
e.errorType.should.equal('uniqueViolated'); | ||
e.key.should.equal(3); | ||
} | ||
@@ -309,3 +314,8 @@ bst.checkIsBST(); | ||
bst.insert(12, 'a'); | ||
(function () { bst.insert(12, 'b'); }).should.throw(); | ||
try { | ||
bst.insert(12, 'world'); | ||
} catch (e) { | ||
e.errorType.should.equal('uniqueViolated'); | ||
e.key.should.equal(12); | ||
} | ||
@@ -312,0 +322,0 @@ bst.checkIsBST(); |
39125
958