Commit fb6e29e8 authored by isovector's avatar isovector Committed by Marge Bot

Add tests

parent fc965c09
Pipeline #24568 passed with stages
in 303 minutes and 43 seconds
......@@ -52,6 +52,10 @@ comparing p x y = compare (p x) (p y)
-- @low@ and @high@. If it is, @a@ is returned unchanged. The result
-- is otherwise @low@ if @a <= low@, or @high@ if @high <= a@.
--
-- When clamp is used at Double and Float, it has NaN propagating semantics in
-- its second argument. That is, @clamp (l,h) NaN = NaN@, but @clamp (NaN, NaN)
-- x = x@.
--
-- >>> clamp (0, 10) 2
-- 2
--
......
......@@ -256,3 +256,4 @@ test('T16943a', normal, compile_and_run, [''])
test('T16943b', normal, compile_and_run, [''])
test('T17499', [collect_stats('bytes allocated',5)], compile_and_run, ['-O -w'])
test('T16643', normal, compile_and_run, [''])
test('clamp', normal, compile_and_run, [''])
import Data.Ord
doClampInt :: (Int, Int) -> Int -> IO ()
doClampInt bounds a = print $ clamp bounds a
doClampFloat :: (Float, Float) -> Float -> IO ()
doClampFloat bounds a = print $ clamp bounds a
nan :: Float
nan = 0 / 0
main :: IO ()
main = do
doClampInt (0, 100) 50 -- 50
doClampInt (0, 100) 200 -- 100
doClampInt (0, 100) (-5) -- 0
doClampFloat (0, 100) 50 -- 50
doClampFloat (0, 100) 200 -- 100
doClampFloat (0, 100) (-5) -- 0
doClampFloat (0, 100) nan -- NaN
doClampFloat (nan, 100) 5 -- 5
doClampFloat (nan, 100) 105 -- 100
doClampFloat (5, nan) 105 -- 105
doClampFloat (5, nan) 3 -- 5
doClampFloat (nan, nan) 3 -- 3
50
100
0
50.0
100.0
0.0
NaN
5.0
100.0
105.0
5.0
3.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment