aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/dynamic.lux
blob: e2564627a4b2d96932295d7e159f61c3db894f4b (plain)
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
(.module:
  [lux #*
   data/text/format
   ["r" math/random (#+ Random)]
   ["_" test (#+ Test)]
   [control ["." monad (#+ do)]]
   [data
    ["." error]]]
  {1
   ["." / (#+ Dynamic :dynamic :check)]})

(def: #export test
  Test
  (<| (_.context (%name (name-of /._)))
      (do r.monad
        [expected r.nat
         #let [value (:dynamic expected)]]
        ($_ _.and
            (_.test "Can check dynamic values."
                    (case (:check Nat value)
                      (#error.Success actual)
                      (n/= expected actual)
                      
                      (#error.Failure error)
                      false))
            (_.test "Cannot confuse types."
                    (case (:check Text value)
                      (#error.Success actual)
                      false
                      
                      (#error.Failure error)
                      true))))))