| 1 |
package.path = '../src/?.lua;' .. package.path |
| 2 |
local tap = require 'tapered' |
| 3 |
local error = error |
| 4 |
|
| 5 |
--- boom |
| 6 |
-- boom(method, arguments, [msg]) tests if the function throws an exception when |
| 7 |
-- given the arguments supplied. The arguments parameter must be a table. It can |
| 8 |
-- be empty if the given method takes no arguments, but it cannot be nil. |
| 9 |
-- |
| 10 |
-- Note that boom expects an exception. It passes if an exception is throw, and |
| 11 |
-- fails if one is not. The exception, however, will be swallowed by boom so |
| 12 |
-- that test execution continues. |
| 13 |
local broken = function (x) return x.__eq end |
| 14 |
local add = function (x, y) return x+y end |
| 15 |
tap.boom(broken, {}, 'ok - return nada.__eq') |
| 16 |
tap.boom(add, {2, 3}, 'not ok - Test boom with a method that throws no exception') |
| 17 |
tap.boom(error, {'Kaboom!'}, |
| 18 |
'ok - Test boom with a method that throws an exception "Kaboom!"') |
| 19 |
tap.done() |