2016-05-13 02:26:52 +00:00
|
|
|
module Main exposing (..)
|
2015-10-13 18:56:46 +00:00
|
|
|
|
2016-03-17 01:38:35 +00:00
|
|
|
import ElmTest exposing (..)
|
|
|
|
import Strain exposing (keep, discard)
|
2015-10-13 18:56:46 +00:00
|
|
|
import String
|
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2016-03-17 01:52:25 +00:00
|
|
|
even : Int -> Bool
|
|
|
|
even number =
|
|
|
|
number % 2 == 0
|
2016-03-17 01:38:51 +00:00
|
|
|
|
|
|
|
|
2016-03-17 01:52:25 +00:00
|
|
|
odd : Int -> Bool
|
|
|
|
odd number =
|
|
|
|
number % 2 == 1
|
2016-03-17 01:38:51 +00:00
|
|
|
|
|
|
|
|
2016-03-17 01:52:25 +00:00
|
|
|
isFirstLetter : String -> String -> Bool
|
|
|
|
isFirstLetter letter word =
|
|
|
|
(String.left 1 word) == letter
|
2016-03-17 01:38:51 +00:00
|
|
|
|
|
|
|
|
2016-03-17 01:52:25 +00:00
|
|
|
lessThanTen : number -> Bool
|
|
|
|
lessThanTen num =
|
|
|
|
num < 10
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-13 18:56:46 +00:00
|
|
|
|
|
|
|
tests : Test
|
2016-03-17 01:38:51 +00:00
|
|
|
tests =
|
|
|
|
suite
|
|
|
|
"Strain"
|
|
|
|
[ test
|
|
|
|
"empty keep"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[]
|
|
|
|
(keep lessThanTen [])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"keep everything"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 1, 2, 3 ]
|
|
|
|
(keep lessThanTen [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"keep first and last"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 1, 3 ]
|
|
|
|
(keep odd [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"keep nothing"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[]
|
|
|
|
(keep even [ 1, 3, 5, 7 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"keep neither first nor last"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 2 ]
|
|
|
|
(keep even [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"keep strings"
|
|
|
|
(assertEqual
|
|
|
|
[ "zebra", "zombies", "zealot" ]
|
|
|
|
(keep (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ])
|
|
|
|
)
|
|
|
|
, test
|
|
|
|
"empty discard"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[]
|
|
|
|
(discard lessThanTen [])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"discard everything"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[]
|
|
|
|
(discard lessThanTen [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"discard first and last"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 2 ]
|
|
|
|
(discard odd [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"discard nothing"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 1, 3, 5, 7 ]
|
|
|
|
(discard even [ 1, 3, 5, 7 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"discard neither first nor last"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ 1, 3 ]
|
|
|
|
(discard even [ 1, 2, 3 ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"discard strings"
|
2016-03-17 01:52:25 +00:00
|
|
|
(assertEqual
|
|
|
|
[ "apple", "banana", "cherimoya" ]
|
|
|
|
(discard (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ])
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
]
|
|
|
|
|
2015-10-13 18:56:46 +00:00
|
|
|
|
2016-05-13 02:26:52 +00:00
|
|
|
main : Program Never
|
|
|
|
main =
|
|
|
|
runSuite tests
|