Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

20 lines (17 sloc) 0.763 kB
import Test.Framework (defaultMain)
import Test.Framework.Providers.QuickCheck2 (testProperty)
import qualified Data.ByteString.Char8 as B
import qualified Data.Double.Conversion.ByteString as B
import qualified Data.Double.Conversion.Text as T
import qualified Data.Text as T
shortest :: (Double -> String) -> Double -> Double -> Bool
shortest f a b = case read (f ab) of
ba | isNaN ba -> isNaN ab
| isInfinite ba -> isInfinite ab && signum ba == signum ab
| otherwise -> ba == ab
where ab = a / b
main :: IO ()
main = defaultMain [
testProperty "b_shortest" $ shortest (B.unpack . B.toShortest)
, testProperty "t_shortest" $ shortest (T.unpack . T.toShortest)
]
Jump to Line
Something went wrong with that request. Please try again.