- Timestamp:
- 02/13/08 18:49:59 (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
fix/eg_test.erl (modified) (2 diffs)
-
src/tests.erl (modified) (1 diff)
-
src/tests_test.erl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fix/eg_test.erl
r17 r18 5 5 -module (eg_test). 6 6 -test (exports). 7 -export ([ok/0, nok/0 ]).7 -export ([ok/0, nok/0, with_fixture/1]). 8 8 9 9 ok () -> … … 12 12 nok () -> 13 13 ok = list_to_existing_atom ("nok"). 14 15 with_fixture (F) -> 16 "data" = F ("data"), 17 ok. -
trunk/src/tests.erl
r17 r18 12 12 13 13 filter_by_attribute (Binary, [exports | Tail], Tests) -> 14 {ok, {Module, [{exports, Exports}]}} = beam_lib: chunks (Binary, [exports]),15 Funs = [fun () -> Module: X () end || {X, 0} <- Exports, X /= module_info],14 {ok, {Module, [{exports, Exports}]}} = beam_lib: chunks (Binary, [exports]), 15 Funs = exports_to_funs (Module, Exports, []), 16 16 filter_by_attribute (Binary, Tail, [Funs | Tests]); 17 17 filter_by_attribute (_, [], Tests) -> 18 18 lists: flatten (Tests). 19 20 exports_to_funs (M, [{module_info, _} | Exports], Funs) -> 21 exports_to_funs (M, Exports, Funs); 22 exports_to_funs (M, [{F, 0} | Exports], Funs) -> 23 Fun = fun (_) -> M: F () end, 24 exports_to_funs (M, Exports, [Fun | Funs]); 25 exports_to_funs (M, [{F, 1} | Exports], Funs) -> 26 Fun = fun (Fix) -> M: F (Fix) end, 27 exports_to_funs (M, Exports, [Fun | Funs]); 28 exports_to_funs (_, [], Funs) -> 29 Funs. -
trunk/src/tests_test.erl
r17 r18 20 20 Binary = modules: to_binary (File_name), 21 21 false = code: is_loaded (eg_test), 22 [ Nok, Ok] = tests: filter_by_attribute (Binary),22 [With_fixture, Ok, Nok] = tests: filter_by_attribute (Binary), 23 23 try 24 24 {module, eg_test} = code: load_binary (eg_test, File_name, Binary), 25 ok = Ok (), 26 {'EXIT', {{badmatch, nok}, _}} = (catch Nok ()) 25 ok = Ok (fun empty_fixture/1), 26 {'EXIT', {{badmatch, nok}, _}} = (catch Nok (fun empty_fixture/1)), 27 ok = With_fixture (fun echo_fixture/1) 27 28 after 28 29 code: purge (eg_test), … … 30 31 end. 31 32 33 empty_fixture (_) -> 34 throw (empty_fixture). 35 36 echo_fixture (X) -> 37 X.
Note: See TracChangeset
for help on using the changeset viewer.
