diff options
author | Richard Carlsson <[email protected]> | 2011-07-18 23:18:32 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-08-30 11:18:32 +0200 |
commit | e70a2fd034793729e10fdba707e7248270116768 (patch) | |
tree | 09c6f3316e6f453f717a923043f1f97f5591ca46 /lib/eunit/src/eunit_test.erl | |
parent | b0b527be0caf7750908e18d2a76a662e4887e8b8 (diff) | |
download | otp-e70a2fd034793729e10fdba707e7248270116768.tar.gz otp-e70a2fd034793729e10fdba707e7248270116768.tar.bz2 otp-e70a2fd034793729e10fdba707e7248270116768.zip |
Updated to EUnit version 2.2.0
New macros assertNotMatch(Guard, Expr), assertNotEqual(Unexpected, Expr),
and assertNotException(Class, Term, Expr).
The debugMsg macro now also prints the pid of the current process.
When testing all modules in a directory, tests in <Module>_tests.erl are
no longer executed twice.
The use of 'regexp' internally has been replaced with 're'.
Diffstat (limited to 'lib/eunit/src/eunit_test.erl')
-rw-r--r-- | lib/eunit/src/eunit_test.erl | 72 |
1 files changed, 67 insertions, 5 deletions
diff --git a/lib/eunit/src/eunit_test.erl b/lib/eunit/src/eunit_test.erl index d322c4b420..9ac1d1e7d9 100644 --- a/lib/eunit/src/eunit_test.erl +++ b/lib/eunit/src/eunit_test.erl @@ -131,12 +131,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 +167,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 +191,7 @@ macro_test_() -> [{module,_}, {line,_}, {expression,_}, - {expected,_}, + {pattern,_}, {unexpected_success,ok}]}, _}} = run_testfun(F) @@ -174,15 +203,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. |