Sha256: f6a12692cac365fd279e1d15d75bf031c8572d2368997d25e598776a9f3caf1d
Contents?: true
Size: 1.42 KB
Versions: 41
Compression:
Stored size: 1.42 KB
Contents
module Test.Accumulate import Accumulate %access export assertEq : Eq a => String -> (given : a) -> (expected : a) -> IO () assertEq label g e = putStrLn $ if g == e then label ++ ": Test Passed" else label ++ ": Test Failed" testEmptyListDoesNothing : IO () testEmptyListDoesNothing = assertEq "empty list does nothing" (accumulate (\x => x) []) (the (List Int) []) testIdentityFunctionDoesNothing : IO () testIdentityFunctionDoesNothing = assertEq "identity function does nothing" (accumulate (\x => x) [1,2,3]) [1,2,3] testSquareFunctionDoublesInput : IO () testSquareFunctionDoublesInput = assertEq "square function doubles input" (accumulate (\x => x * x) [1,2,3]) [1,4,9] testCubeFunctionTriplesInput : IO () testCubeFunctionTriplesInput = assertEq "cube function triples input" (accumulate (\x => x * x * x) [1,2,3]) [1,8,27] testIncrementFunctionAddsOneToAllInput : IO () testIncrementFunctionAddsOneToAllInput = assertEq "increment function adds 1 to input" (accumulate (\x => x + 1) [1,2,3]) [2,3,4] testDecrementFunctionAddsOneToAllInput : IO () testDecrementFunctionAddsOneToAllInput = assertEq "decrement function subtracts 1 from input" (accumulate (\x => x - 1) [1,2,3]) (the (List Int) [0,1,2]) runTests : IO () runTests = do testEmptyListDoesNothing testIdentityFunctionDoesNothing testSquareFunctionDoublesInput testCubeFunctionTriplesInput testIncrementFunctionAddsOneToAllInput testDecrementFunctionAddsOneToAllInput
Version data entries
41 entries across 41 versions & 1 rubygems