aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/implicit.lux
blob: dffd9496cff3803598b156d90191b4640ebb3450 (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
33
34
35
36
37
38
39
40
(.module:
  [lux #*
   [io]
   [control
    [equivalence]
    [functor]
    [monad (#+ Monad do)]]
   [data
    ["." bit ("#;." equivalence)]
    [number]
    [collection [list]]]
   [math
    ["r" random]]
   [type implicit]]
  lux/test)

(context: "Automatic structure selection"
  (<| (times 100)
      (do @
        [x r.nat
         y r.nat]
        ($_ seq
            (test "Can automatically select first-order structures."
                  (let [(^open "list;.") (list.equivalence number.equivalence)]
                    (and (bit;= (:: number.equivalence = x y)
                                (::: = x y))
                         (list;= (list.n/range 1 10)
                                 (::: map inc (list.n/range 0 9)))
                         )))
            
            (test "Can automatically select second-order structures."
                  (::: =
                    (list.n/range 1 10)
                    (list.n/range 1 10)))

            (test "Can automatically select third-order structures."
                  (let [lln (::: map (list.n/range 1)
                              (list.n/range 1 10))]
                    (::: = lln lln)))
            ))))