% $Id: TestingNoStop.oz,v 1.3 2007/10/22 04:35:54 leavens Exp leavens $ % % Assertion and testing procedures for Oz that do not stop % (you have to check the output) % % AUTHOR: Gary T. Leavens, using ideas from Jeff Balogh declare %% Assert that the argument is true. proc {Assert B} if {Not B} then {System.showInfo 'ASSERTION FAILED!'} end end %% Assert that the second argument is true. proc {AssertTrue Message B} if {Not B} then {System.showInfo 'ASSERTION FAILED: ' # Message} end end %% Assert that the second argument is false. proc {AssertFalse Message B} {AssertTrue Message {Not B}} end %% Mark an assumption that the argument is true. proc {Assume B} if {Not B} then {System.showInfo 'ASSUMPTION FAILED!'} end end %% Mark an assumption that the second argument is true. proc {AssumeTrue Message B} if {Not B} then {System.showInfo 'ASSUMPTION FAILED: ' # Message} end end %% Mark an assumption that the second argument is false. proc {AssumeFalse Message B} {AssumeTrue Message {Not B}} end %% Print a newline and a message that testing is beginning. proc {StartTesting Name} {System.showInfo ""} {System.showInfo 'Testing ' # Name # '...'} end %% Test if Actual == Expected. %% If so, print a message, otherwise output a failure message. proc {Test Actual Connective Expected} if Actual == Expected then {System.showInfo {Value.toVirtualString Actual 5 20} # ' ' # Connective # ' ' # {Value.toVirtualString Expected 5 20}} else {System.showInfo 'TEST FAILURE: ' # {Value.toVirtualString Actual 5 20} # ' ' # Connective # ' ' # {Value.toVirtualString Expected 5 20} } end end