aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/compiler/reference.lux
blob: a0bd549bc7ae8b626ce3854d37d2ec8b44dfc3db (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
91
92
93
94
95
96
97
98
99
100
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]
    ["[0]" equivalence
     ["[1]T" \\test]]
    ["[0]" hash
     ["[1]T" \\test]]]
   [data
    ["[0]" text (.use "[1]#[0]" equivalence)
     ["%" \\format]]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]]]
   [meta
    ["[0]" symbol (.use "[1]#[0]" equivalence)]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" / (.only)
   ["[0]" variable (.only Register)]]]
 ["[0]" /
  ["[1][0]" variable]])

(def constant
  (Random /.Constant)
  (all random.and
       (random.upper_cased 5)
       (random.lower_cased 5)
       ))

(def .public random
  (Random /.Reference)
  (all random.or
       /variable.random
       ..constant
       ))

(def .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Reference
              /.#Constant /.#Variable

              /.Constant])
      (do random.monad
        [expected_register random.nat
         expected_constant ..constant])
      (`` (all _.and
               (_.for [/.equivalence]
                      (equivalenceT.spec /.equivalence ..random))
               (_.for [/.hash]
                      (hashT.spec /.hash ..random))

               (,, (with_template [<tag>]
                     [(_.coverage [<tag>]
                        (when (<tag> expected_register)
                          (<tag> actual_register)
                          (n.= expected_register actual_register)

                          _
                          false))]

                     [/.local]
                     [/.foreign]
                     ))

               (_.coverage [/.variable /.self]
                 (and (of /.equivalence = (/.self) (/.variable (variable.self)))
                      (when (/.self)
                        (/.self)
                        true
                        
                        _
                        false)
                      (when (/.variable (variable.self))
                        (/.self)
                        true
                        
                        _
                        false)))
               (_.coverage [/.constant]
                 (when (/.constant expected_constant)
                   (/.constant actual_constant)
                   (symbol#= expected_constant actual_constant)

                   _
                   false))
               (_.coverage [/.format]
                 (and (text#= (/.format (/.local expected_register))
                              (variable.format {variable.#Local expected_register}))
                      (text#= (/.format (/.foreign expected_register))
                              (variable.format {variable.#Foreign expected_register}))
                      (text#= (/.format (/.constant expected_constant))
                              (%.symbol expected_constant))))
               
               /variable.test
               ))))