Add 'throws'/'notThrows' assertion to Ospec for error reporting (#2255)
* Ospec: added assertion that function does/doesnt throw error * Ospec.throws passes npm test * Ospec.throws: Address requested changes * Ospec: message comparison support for .throws/.notthrows Credit to @maranomynet, #2227
This commit is contained in:
parent
22427db882
commit
0fd1bc9cae
4 changed files with 40 additions and 1 deletions
|
|
@ -163,6 +163,14 @@ o.spec("ospec", function() {
|
|||
o(a).notEquals(2)
|
||||
o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3})
|
||||
o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}])
|
||||
o(function(){throw new Error()}).throws(Error)
|
||||
o(function(){"ayy".foo()}).throws(TypeError)
|
||||
o(function(){Math.PI.toFixed(Math.pow(10,20))}).throws(RangeError)
|
||||
o(function(){decodeURIComponent("%")}).throws(URIError)
|
||||
|
||||
o(function(){"ayy".foo()}).notThrows(SyntaxError)
|
||||
o(function(){throw new Error("foo")}).throws("foo")
|
||||
o(function(){throw new Error("foo")}).notThrows("bar")
|
||||
|
||||
var undef1 = {undef: void 0}
|
||||
var undef2 = {UNDEF: void 0}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue