HUnit-approx-1.0: Approximate equality for floating point numbers with HUnit

Portabilitynot portable (uses implicit parameters)
Stabilityintended to be stable
MaintainerRichard Eisenberg (eir@cis.upenn.edu)
Safe HaskellNone

Test.HUnit.Approx

Contents

Description

This module exports combinators to allow approximate equality of floating-point values in HUnit tests.

Synopsis

Assertions

assertApproxEqualSource

Arguments

:: (Ord a, Num a, Show a) 
=> String

The message prefix

-> a

Maximum allowable margin of error

-> a

The expected value

-> a

The actual value

-> Assertion 

Asserts that the specified actual value is approximately equal to the expected value. The output message will contain the prefix, the expected value, the actual value, and the maximum margin of error.

If the prefix is the empty string (i.e., ""), then the prefix is omitted and only the expected and actual values are output.

(@~?)Source

Arguments

:: (Ord a, Num a, Show a, [epsilon :: a]) 
=> a

The expected value

-> a

The actual value

-> Assertion 

Asserts that the specified actual value is approximately equal to the expected value (with the expected value on the left-hand side). The margin of error is specified with the implicit parameter epsilon.

(@?~)Source

Arguments

:: (Ord a, Num a, Show a, [epsilon :: a]) 
=> a

The actual value

-> a

The expected value

-> Assertion 

Asserts that the specified actual value is approximately equal to the expected value (with the expected value on the right-hand side). The margin of error is specified with the implicit parameter epsilon.

Tests

(~~?)Source

Arguments

:: (Ord a, Num a, Show a, [epsilon :: a]) 
=> a

The expected value

-> a

The actual value

-> Test 

Shorthand for a test case that asserts approximate equality (with the expected value on the left-hand side, and the actual value on the right-hand side).

(~?~)Source

Arguments

:: (Ord a, Num a, Show a, [epsilon :: a]) 
=> a

The actual value

-> a

The expected value

-> Test 

Shorthand for a test case that asserts approximate equality (with the actual value on the left-hand side, and the expected value on the right-hand side).