on 577fc17 help sign in
38 lines 1.8 kB history raw
1module Test.List (tests) where
3import List
5import ElmTest.Assertion (..)
6import ElmTest.Test (..)
8tests : Test
9tests =
10 let partitionTests =
11 let p1 = id
12 p2 x = x < 3
13 isEven n = n `mod` 2 == 0
14 in suite "partition Tests" [ test "simple partition" <| assertEqual ([True],[False]) (List.partition p1 [False, True]),
15 test "order check" <| assertEqual ([2,1], [5,6]) (List.partition p2 [2,5,6,1]),
16 test "partition doc check 1" <| assertEqual ([0,1,2], [3,4,5]) (partition p2 [0..5]),
17 test "partition doc check 2" <| assertEqual ([0,2,4], [1,3,5]) (partition isEven [0..5]),
18 let n = 100000
19 ts = repeat n True
20 fs = repeat n False
21 in test "partition stress test" <| assertEqual (ts, fs) (partition p1 (fs++ts))
22 ]
23 unzipTests = suite "unzip Tests" [
24 test "unzip doc check" <| assertEqual ([0,17,1337],[True,False,True]) (unzip [(0, True), (17, False), (1337, True)]),
25 let n = 100000
26 ts = repeat n True
27 fs = repeat n False
28 in test "unzip stress test" <| assertEqual (ts, fs) (unzip (zip ts fs))
29 ]
30 intersperseTests = suite "intersperse Tests" [
31 test "intersperse doc check" <| assertEqual ["turtles","on","turtles","on","turtles"] (intersperse "on" ["turtles","turtles","turtles"]),
32 let n = 100000
33 ts = repeat n True
34 fs = repeat n False
35 in test "intersperse stress test" <| assertEqual (tail . List.concat <| zipWith (\x y -> [x,y]) fs ts)
36 (intersperse False ts)
37 ]
38 in suite "List Tests" [partitionTests, unzipTests, intersperseTests]