aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux
blob: 565903706aa906417566f343a53d4d5f473b3913 (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
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" io]
    ["[0]" try]]
   [data
    ["[0]" bit (.use "[1]#[0]" equivalence)]
    ["[0]" text (.use "[1]#[0]" equivalence)]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["[0]" int (.use "[1]#[0]" equivalence)]
     ["[0]" frac (.use "[1]#[0]" equivalence)]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" / (.only)
   [//
    ["[0]" host]]]])

(def .public test
  Test
  (<| (_.covering /._)
      (do [! random.monad]
        [expected_bit random.bit
         expected_i64 random.i64
         expected_f64 random.frac
         expected_text (random.lower_cased 1)])
      (`` (all _.and
               (,, (with_template [<constructor> <expected> <type> <=>]
                     [(_.coverage [<constructor>]
                        (io.run! (do io.monad
                                   [[class_loader host] host.host]
                                   (in (when (of host evaluate [{.#None} (<constructor> <expected>)])
                                         {try.#Success actual}
                                         (<=> <expected> (as <type> actual))
                                         
                                         {try.#Failure error}
                                         false)))))]

                     [/.bit expected_bit Bit bit#=]
                     [/.i64 expected_i64 Int int#=]
                     [/.f64 expected_f64 Frac frac#=]
                     [/.text expected_text Text text#=]
                     ))
               ))))