on 2a930fd help sign in
elk/tests/libraries/Test/CodeGen.elm
55 lines 1.2 kB history raw
1module Test.CodeGen (tests) where
3import ElmTest.Assertion (..)
4import ElmTest.Test (..)
6import Maybe
7import Maybe (..)
9casePrime m' =
10 case m' of
11 Just x -> x
12 Nothing -> 0
14patternPrime =
15 case Just 42 of
16 Just x' -> x'
17 Nothing -> 0
19letQualified =
20 let (Maybe.Just x) = Just 42
21 in x
23caseQualified =
24 case Just 42 of
25 Maybe.Just x -> x
26 Nothing -> 0
28caseScope : String
29caseScope =
30 case "Not this one!" of
31 string ->
32 case "Hi" of
33 string -> string
35tests : Test
36tests =
37 let primes =
38 suite "Primes"
39 [ test "case" <| assertEqual 42 (casePrime (Just 42))
40 , test "pattern" <| assertEqual 42 patternPrime
41 ]
42 qualifiedPatterns =
43 suite "Qualified Patterns"
44 [ test "let" <| assertEqual 42 letQualified
45 , test "case" <| assertEqual 42 caseQualified
46 ]
47 scope =
48 suite "Scoping"
49 [ test "case" <| assertEqual "Hi" caseScope ]
50 in
51 suite "CodeGen"
52 [ primes
53 , qualifiedPatterns
54 , scope
55 ]