Show
Ignore:
Timestamp:
04/25/08 02:24:26 (6 months ago)
Author:
pmoura
Message:

Corrected a bug in the library object "lgtunit" when running "throws" tests (make sure the generated exception is subsumed by the expected exception). Added a "lgtunit_loader" loader utility file for loading the Logtalk unit test library.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/library/lgtunit.lgt

    r3825 r4224  
    33 
    44    :- info([ 
    5         version is 0.2, 
     5        version is 0.3, 
    66        author is 'Paulo Moura', 
    7         date is 2007/08/27, 
     7        date is 2008/04/25, 
    88        comment is 'Logtalk unit test framework.']). 
     9 
     10    :- uses(term, [subsumes/2]). 
    911 
    1012    :- public(succeeds/2). 
     
    1214    :- info(succeeds/2, [ 
    1315        comment is 'Defines a test goal which is expected to succeed.', 
    14         argnames is ['Test', 'Goal']]). 
     16        argnames is ['Identifier', 'Goal']]). 
    1517 
    1618    :- public(fails/2). 
     
    1820    :- info(fails/2, [ 
    1921        comment is 'Defines a test goal which is expected to fail.', 
    20         argnames is ['Test', 'Goal']]). 
     22        argnames is ['Identifier', 'Goal']]). 
    2123 
    2224    :- public(throws/3). 
     
    2426    :- info(throws/3, [ 
    2527        comment is 'Defines a test goal which is expected to throw an error.', 
    26         argnames is ['Test', 'Goal', 'Error']]). 
     28        argnames is ['Identifier', 'Goal', 'Error']]). 
    2729 
    2830    :- public(run/2). 
     
    8385 
    8486    test_throws(Test, Goal, Error) :- 
    85         (   catch({Goal}, Ball, ((Ball = Error -> passed_test(Test, Goal); failed_test(Test, Goal)), Flag = error)) -> 
     87        (   catch({Goal}, Ball, ((subsumes(Error, Ball) -> passed_test(Test, Goal); failed_test(Test, Goal)), Flag = error)) -> 
    8688            (   var(Flag) -> 
    8789                failed_test(Test, Goal)