%%% $Id: FloatTestingTest.oz,v 1.1 2006/10/26 15:12:23 leavens Exp $ declare [Testing FloatTesting] = {Module.link ['Testing.ozf' 'FloatTesting.ozf']} {Testing.start 'FloatTesting'} X = 3.0 {Testing.assert 0.0 < FloatTesting.standardTolerance} {Testing.assert FloatTesting.standardTolerance < 1.0} {FloatTesting.withinTest X '==' 3.0} {FloatTesting.withinTest 1.0/3.0 '==' 0.33333} {FloatTesting.relativeTest X '==' 3.0} {FloatTesting.relativeTest 1.0/3.0 '==' 0.33333} local B EX in try {FloatTesting.withinTest 1.0/3.0 '==' 0.3323} B = false catch EXC then B = true EX=EXC end if B then {System.showInfo 'correctly caught ' # {Value.toVirtualString EX 5 10}} {System.showInfo 'ok'} else {System.showInfo 'failed'} raise testDidntWork end end end local B EX in try {FloatTesting.relativeTest 1.0/3.0 '==' 0.3323} B = false catch EXC then B = true EX=EXC end if B then {System.showInfo 'correctly caught ' # {Value.toVirtualString EX 5 10}} {System.showInfo 'ok'} else {System.showInfo 'failed'} raise testDidntWork end end end {FloatTesting.withinTest [X] '==' [3.0]} {FloatTesting.withinTest [X 1.0/3.0] '==' [3.0 0.33333]} {FloatTesting.relativeTest [X] '==' [3.0]} {FloatTesting.relativeTest [X 1.0/3.0] '==' [3.0 0.33333]} {System.showInfo 'ok'}