One more test.

This commit is contained in:
Erik Svedäng 2020-04-30 12:56:04 +02:00
parent 81bad8795c
commit 234aa9fe60
2 changed files with 13 additions and 6 deletions

View File

@ -73,6 +73,8 @@
(Just x) (IO.println &x)
(Nothing) (IO.println "nada"))))
(defn g []
(match-ref &(Just (Just @"foooo"))
(Just (Just x)) (IO.println x)))
(defn deep [x]
(match-ref x
(Nothing) (IO.println "nothing")
(Just (Nothing)) (IO.println "just nothing")
(Just (Just x)) (IO.println x)))

View File

@ -35,12 +35,17 @@
(Nest.Nested (Nest.Nested (Nest.Nested x)))
x)
"Match matches nested sumtype constructors with variables")
(assert-equal test
"hello"
(let [m (Maybe.Just @"hello")]
(match-ref &m
(Maybe.Nothing) "wrong"
(Maybe.Just x ) x))
"match-ref works on simple sumtype")
(assert-equal test
"found"
(let [n (Nest.Nested (Nest.Nested (Nest.Nested @"found")))]
(match-ref &n
(Nest.Nested (Nest.Nested (Nest.Nested s))) s))
"match-ref works on deeply nested sumtype"
)
"match-ref works on deeply nested sumtype")
)