summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoreliaslfox <>2018-11-02 20:16:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-11-02 20:16:00 (GMT)
commit758bcb2e1be97a3c03822fd1360606034a1ab8a6 (patch)
treef6ca10a5ee7e6bdd3d4d4b9b0c9cc544194ddfb9 /test
parent49cd3de06b1aafc0fd3219fc3e06a071e7ce168c (diff)
version 0.1.1.10.1.1.1
Diffstat (limited to 'test')
-rw-r--r--test/program1.elm46
-rw-r--r--test/spec/case1.txt6
-rw-r--r--test/spec/dec1.txt3
-rw-r--r--test/spec/dec2.txt8
-rw-r--r--test/spec/dec3.txt3
-rw-r--r--test/spec/dec4.txt2
-rw-r--r--test/spec/let1.txt4
-rw-r--r--test/spec/let2.txt5
8 files changed, 77 insertions, 0 deletions
diff --git a/test/program1.elm b/test/program1.elm
new file mode 100644
index 0000000..cf700a3
--- /dev/null
+++ b/test/program1.elm
@@ -0,0 +1,46 @@
+module Maybe exposing (Maybe(Just, Nothing), andThen, map, map2, map3, map4, map5, withDefault)
+
+
+type Maybe a
+ = Nothing
+ | Just a
+
+
+withDefault : a -> Maybe a -> a
+withDefault default maybe =
+ case maybe of
+ Just value ->
+ value
+
+ Nothing ->
+ default
+
+
+map : (a -> b) -> Maybe a -> Maybe b
+map f maybe =
+ case maybe of
+ Just value ->
+ Just (f value)
+
+ Nothing ->
+ Nothing
+
+
+map2 : (a -> b -> value) -> Maybe a -> Maybe b -> Maybe value
+map2 func ma mb =
+ case ( ma, mb ) of
+ ( Just a, Just b ) ->
+ Just (func a b)
+
+ _ ->
+ Nothing
+
+
+map3 : (a -> b -> c -> value) -> Maybe a -> Maybe b -> Maybe c -> Maybe value
+map3 func ma mb mc =
+ case ( ma, mb, mc ) of
+ ( Just a, Just b, Just c ) ->
+ Just (func a b c)
+
+ _ ->
+ Nothing
diff --git a/test/spec/case1.txt b/test/spec/case1.txt
new file mode 100644
index 0000000..ae0c5f6
--- /dev/null
+++ b/test/spec/case1.txt
@@ -0,0 +1,6 @@
+case m of
+ Just x ->
+ x
+
+ Nothing ->
+ 0
diff --git a/test/spec/dec1.txt b/test/spec/dec1.txt
new file mode 100644
index 0000000..7dfbc05
--- /dev/null
+++ b/test/spec/dec1.txt
@@ -0,0 +1,3 @@
+add5 : Int -> Int
+add5 x =
+ x + 5
diff --git a/test/spec/dec2.txt b/test/spec/dec2.txt
new file mode 100644
index 0000000..ced6ccd
--- /dev/null
+++ b/test/spec/dec2.txt
@@ -0,0 +1,8 @@
+withDefault : a -> Maybe a -> a
+withDefault default m =
+ case m of
+ Just x ->
+ x
+
+ Nothing ->
+ default
diff --git a/test/spec/dec3.txt b/test/spec/dec3.txt
new file mode 100644
index 0000000..4b933ef
--- /dev/null
+++ b/test/spec/dec3.txt
@@ -0,0 +1,3 @@
+type Maybe a
+ = Nothing
+ | Just a
diff --git a/test/spec/dec4.txt b/test/spec/dec4.txt
new file mode 100644
index 0000000..9abf93d
--- /dev/null
+++ b/test/spec/dec4.txt
@@ -0,0 +1,2 @@
+type alias Model a =
+ Maybe a
diff --git a/test/spec/let1.txt b/test/spec/let1.txt
new file mode 100644
index 0000000..59db4f9
--- /dev/null
+++ b/test/spec/let1.txt
@@ -0,0 +1,4 @@
+let
+ a = 5
+in
+ a
diff --git a/test/spec/let2.txt b/test/spec/let2.txt
new file mode 100644
index 0000000..b4f6f77
--- /dev/null
+++ b/test/spec/let2.txt
@@ -0,0 +1,5 @@
+let
+ a = 5
+ b = 6
+in
+ a + b