Changeset 34 for trunk/src/tests.erl


Ignore:
Timestamp:
08/22/08 18:46:07 (4 years ago)
Author:
dom
Message:

Removed everything related to fixtures while the concept matures a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tests.erl

    r33 r34  
    1010    {Module, [{attributes, Attributes}]} = Chunks, 
    1111    Declarations = lists: flatten ([T || {test, T} <- Attributes]), 
    12     filter_by_attribute (Module, Binary, Declarations, []). 
     12    Tests = filter (Binary, Declarations, []), 
     13    {Module, Tests}. 
     14 
     15filter (Binary, [exports | Tail], Acc) -> 
     16    {ok, Chunks} = beam_lib: chunks (Binary, [exports]), 
     17    {_, [{exports, Exports}]} = Chunks, 
     18    Tests = lists: foldl (fun testable_export/2, [], Exports), 
     19    filter (Binary, Tail, [Tests | Acc]); 
     20filter (_, [], Acc) -> 
     21    lists: flatten (Acc). 
     22 
     23testable_export ({module_info, _}, Fs) -> Fs; 
     24testable_export ({F, 0}, Fs) -> [F | Fs]; 
     25testable_export (_, Fs) -> Fs. 
    1326 
    1427receive_all () -> 
    1528    receive_all ([]). 
    16  
    17 filter_by_attribute (Module, Binary, [exports | Tail], Tests) -> 
    18     {ok, Chunks} = beam_lib: chunks (Binary, [exports]), 
    19     {Module, [{exports, Exports}]} = Chunks, 
    20     Funs = exports_to_funs (Module, Exports, []), 
    21     filter_by_attribute (Module, Binary, Tail, [Funs | Tests]); 
    22 filter_by_attribute (Module, Binary, [{M, F, Ts} | Tail], Tests) -> 
    23     Funs = [{Module, T} || T <- Ts], 
    24     filter_by_attribute (Module, Binary, Tail, [{M, F, [Funs]} | Tests]); 
    25 filter_by_attribute (Module, _, [], Tests) -> 
    26     {Module, lists: flatten (Tests)}. 
    27  
    28 exports_to_funs (M, [{module_info, _} | Exports], Funs) -> 
    29     exports_to_funs (M, Exports, Funs); 
    30 exports_to_funs (M, [{F, 0} | Exports], Funs) -> 
    31     exports_to_funs (M, Exports, [{M, F, []} | Funs]); 
    32 exports_to_funs (M, [{_, _} | Exports], Funs) -> 
    33     exports_to_funs (M, Exports, Funs); 
    34 exports_to_funs (_, [], Funs) -> 
    35     Funs. 
    3629 
    3730receive_all (Ms) -> 
Note: See TracChangeset for help on using the changeset viewer.