aboutsummaryrefslogtreecommitdiffstats
path: root/lib/eunit/src/eunit_test.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/eunit/src/eunit_test.erl')
-rw-r--r--lib/eunit/src/eunit_test.erl76
1 files changed, 68 insertions, 8 deletions
diff --git a/lib/eunit/src/eunit_test.erl b/lib/eunit/src/eunit_test.erl
index d322c4b420..bca49ae626 100644
--- a/lib/eunit/src/eunit_test.erl
+++ b/lib/eunit/src/eunit_test.erl
@@ -13,9 +13,7 @@
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
%% USA
%%
-%% $Id: eunit_test.erl 336 2009-03-06 14:43:21Z rcarlsson $
-%%
-%% @author Richard Carlsson <[email protected]>
+%% @author Richard Carlsson <[email protected]>
%% @copyright 2006 Richard Carlsson
%% @private
%% @see eunit
@@ -131,12 +129,27 @@ macro_test_() ->
[{module,_},
{line,_},
{expression,_},
- {expected,"[ _ ]"},
+ {pattern,"[ _ ]"},
{value,[]}]},
_}}
= run_testfun(F)
end),
?_test(begin
+ {?LINE, F} = ?_assertNotMatch(ok, error),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertNotMatch([_], [42]),
+ {error,{error,{assertNotMatch_failed,
+ [{module,_},
+ {line,_},
+ {expression,_},
+ {pattern,"[ _ ]"},
+ {value,[42]}]},
+ _}}
+ = run_testfun(F)
+ end),
+ ?_test(begin
{?LINE, F} = ?_assertEqual(ok, ok),
{ok, ok} = run_testfun(F)
end),
@@ -152,6 +165,20 @@ macro_test_() ->
= run_testfun(F)
end),
?_test(begin
+ {?LINE, F} = ?_assertNotEqual(1, 0),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertNotEqual(2, 1+1),
+ {error,{error,{assertNotEqual_failed,
+ [{module,_},
+ {line,_},
+ {expression,_},
+ {value,2}]},
+ _}}
+ = run_testfun(F)
+ end),
+ ?_test(begin
{?LINE, F} = ?_assertException(error, badarith,
erlang:error(badarith)),
{ok, ok} = run_testfun(F)
@@ -162,7 +189,7 @@ macro_test_() ->
[{module,_},
{line,_},
{expression,_},
- {expected,_},
+ {pattern,_},
{unexpected_success,ok}]},
_}}
= run_testfun(F)
@@ -174,15 +201,48 @@ macro_test_() ->
[{module,_},
{line,_},
{expression,_},
- {expected,_},
+ {pattern,_},
+ {unexpected_exception,
+ {error,badarith,_}}]},
+ _}}
+ = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertError(badarith,
+ erlang:error(badarith)),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertExit(normal, exit(normal)),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertThrow(foo, throw(foo)),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertNotException(error, badarith, 42),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertNotException(error, badarith,
+ erlang:error(badarg)),
+ {ok, ok} = run_testfun(F)
+ end),
+ ?_test(begin
+ {?LINE, F} = ?_assertNotException(error, badarith,
+ erlang:error(badarith)),
+ {error,{error,{assertNotException_failed,
+ [{module,_},
+ {line,_},
+ {expression,_},
+ {pattern,_},
{unexpected_exception,
{error,badarith,_}}]},
_}}
= run_testfun(F)
end)
]}.
-
-under_eunit_test() -> ?assert(?UNDER_EUNIT).
-endif.