1
exercism fetch elm list-ops

tests/Tests.elm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
module Tests exposing (..)

import Test exposing (..)
import Expect
import ListOps exposing (..)


tests : Test
tests =
    describe "List Ops"
        [ describe "length"
            [ test "empty list" <|
                \() -> Expect.equal 0 (ListOps.length [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal 4 (ListOps.length (List.range 1 4))
            ]
        , describe "reverse"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal [] (ListOps.reverse [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse (List.range 1 4))
            ]
        , describe "map"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal [] (ListOps.map ((+) 1) [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal (List.range 2 5) (ListOps.map ((+) 1) (List.range 1 4))
            ]
        , describe "filter"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal [] (ListOps.filter (\_ -> True) [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) (List.range 1 4))
            ]
        , describe "foldl"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal 0 (ListOps.foldl (+) 0 [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal 10 (ListOps.foldl (+) 0 (List.range 1 4))
            , skip <|
                test "direction" <|
                    \() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] (List.range 1 4))
            ]
        , describe "foldr"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal 0 (ListOps.foldr (+) 0 [])
            , skip <|
                test "non-empty list" <|
                    \() -> Expect.equal 10 (ListOps.foldr (+) 0 (List.range 1 4))
            , skip <|
                test "direction" <|
                    \() -> Expect.equal (List.range 1 4) (ListOps.foldr (::) [] (List.range 1 4))
            ]
        , describe "append"
            [ skip <|
                test "empty lists" <|
                    \() -> Expect.equal [] (ListOps.append [] [])
            , skip <|
                test "empty and non-empty lists" <|
                    \() -> Expect.equal (List.range 1 4) (ListOps.append [] (List.range 1 4))
            , skip <|
                test "non-empty and empty lists" <|
                    \() -> Expect.equal (List.range 1 4) (ListOps.append (List.range 1 4) [])
            , skip <|
                test "non-empty lists" <|
                    \() -> Expect.equal (List.range 1 8) (ListOps.append (List.range 1 4) (List.range 5 8))
            ]
        , describe "concat"
            [ skip <|
                test "empty list" <|
                    \() -> Expect.equal [] (ListOps.concat [])
            , skip <|
                test "list of lists" <|
                    \() -> Expect.equal (List.range 1 10) (ListOps.concat [ List.range 1 3, [], List.range 4 7, List.range 8 10 ])
            ]
        ]

tests/elm-package.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
    "version": "3.0.0",
    "summary": "Exercism problems in Elm.",
    "repository": "https://github.com/exercism/elm.git",
    "license": "BSD3",
    "source-directories": [
        ".",
        ".."
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "5.0.0 <= v < 6.0.0",
        "elm-community/elm-test": "4.0.0 <= v < 5.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
}