Changeset 20 for trunk


Ignore:
Timestamp:
02/21/08 18:54:15 (4 years ago)
Author:
dom
Message:

Refactoring: extract function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tests_test.erl

    r19 r20  
    1919filtering_tests_returns_list_of_funs_from_unloaded_binary () -> 
    2020    File_name = "../fix/eg_test.erl", 
    21     Binary = modules: to_binary (File_name), 
    22     false = code: is_loaded (eg_test), 
    23     [Ok, Nok] = tests: filter_by_attribute (Binary), 
    24     try 
    25         {module, eg_test} = code: load_binary (eg_test, File_name, Binary), 
    26         ok = Ok (), 
    27         {'EXIT', {{badmatch, nok}, _}} = (catch Nok ()) 
    28     after 
    29         code: purge (eg_test), 
    30         code: delete (eg_test) 
    31     end. 
     21    Test = fun ([Ok, Nok]) -> 
     22                   ok = Ok (), 
     23                   {'EXIT', {{badmatch, nok}, _}} = (catch Nok ()) 
     24           end, 
     25    filtering (File_name, eg_test, Test). 
    3226 
    3327filtering_fixtured_tests_returns_list_of_fixture_fun_tuples () -> 
    3428    File_name = "../fix/eg_test_with_fixture.erl", 
     29    Test = fun ([{Module, Fixture, Tests}]) -> 
     30                   [ok] = Module: Fixture (Tests) 
     31           end, 
     32    filtering (File_name, eg_test_with_fixture, Test). 
     33     
     34filtering (File_name, Module, Test) -> 
    3535    Binary = modules: to_binary (File_name), 
    36     [{Module, Fixture, Tests}] = tests: filter_by_attribute (Binary), 
     36    false = code: is_loaded (Module), 
     37    Tests = tests: filter_by_attribute (Binary), 
    3738    try 
    38         {module, eg_test_with_fixture} = 
    39           code: load_binary (eg_test_with_fixture, File_name, Binary), 
    40         [ok] = Module:Fixture (Tests) 
     39        {module, Module} = code: load_binary (Module, File_name, Binary), 
     40        Test (Tests) 
    4141    after 
    42         code: purge (eg_test_with_fixture), 
    43         code: delete (eg_test_with_fixture) 
     42        code: purge (Module), 
     43        code: delete (Module) 
    4444    end. 
    45      
Note: See TracChangeset for help on using the changeset viewer.