aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/type/nominal.lux
blob: c0bf302976eb654f60ce2a5afd01c18e574ce2cf (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try]
    ["[0]" exception]]
   [data
    ["[0]" text (.use "[1]#[0]" equivalence)]]
   [math
    ["[0]" random]
    [number
     ["n" nat]]]
   ["[0]" meta (.only)
    ["[0]" code (.only)
     ["<[1]>" \\parser]]
    ["[0]" macro (.only)
     [syntax (.only syntax)]
     ["[0]" template]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(template.with_locals [g!Foo g!Bar]
  (these (with_template [<syntax> <meta>]
           [(def <syntax>
              (syntax (_ [])
                (do meta.monad
                  [frame <meta>]
                  (in (list (code.text (the /.#name frame)))))))]

           [current /.current]
           [specific (/.specific (template.text [g!Foo]))]
           )

         (/.def (g!Foo a)
           Text

           (/.def (g!Bar a)
             Nat

             (def .public test
               Test
               (<| (_.covering /._)
                   (_.for [/.def])
                   (do random.monad
                     [expected_foo (random.lower_cased 5)
                      expected_bar random.nat]
                     (all _.and
                          (_.coverage [/.abstraction]
                            (and (exec (is (g!Foo Text)
                                           (/.abstraction g!Foo expected_foo))
                                   true)
                                 (exec (is (g!Bar Text)
                                           (/.abstraction expected_bar))
                                   true)))
                          (_.coverage [/.representation]
                            (and (|> expected_foo
                                     (/.abstraction g!Foo)
                                     (is (g!Foo Bit))
                                     (/.representation g!Foo)
                                     (text#= expected_foo))
                                 (|> (/.abstraction expected_bar)
                                     (is (g!Bar Bit))
                                     /.representation
                                     (n.= expected_bar))))
                          (_.coverage [/.transmutation]
                            (and (exec (|> expected_foo
                                           (/.abstraction g!Foo)
                                           (is (g!Foo .Macro))
                                           (/.transmutation g!Foo)
                                           (is (g!Foo .Lux)))
                                   true)
                                 (exec (|> (/.abstraction expected_bar)
                                           (is (g!Bar .Macro))
                                           /.transmutation
                                           (is (g!Bar .Lux)))
                                   true)))
                          (_.for [/.Frame]
                                 (all _.and
                                      (_.coverage [/.current]
                                        (text#= (template.text [g!Bar])
                                                (..current)))
                                      (_.coverage [/.specific]
                                        (text#= (template.text [g!Foo])
                                                (..specific)))
                                      ))
                          ))))))))