aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/dynamic.lux
blob: 70e26f743040ccfbfaf1c2045396cc45db3becf3 (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
(.module:
  [lux #*
   [control
    [monad (#+ do)]]
   [data
    ["." error]]
   [math
    ["r" random]]
   [type
    ["/" dynamic (#+ Dynamic :dynamic :check)]]]
  lux/test)

(context: "Dynamic typing."
  (do @
    [expected r.nat
     #let [value (:dynamic expected)]]
    ($_ seq
        (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)))))