aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/lang/translation/primitive.lux
blob: 43886e19775eb43c7c2f5c4b887b78d0a2bacbf2 (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
(.module:
  lux
  (lux [io #+ IO]
       (control [monad #+ do]
                pipe)
       (data text/format
             ["e" error]
             [bool "bool/" Eq<Bool>]
             [text "text/" Eq<Text>])
       ["r" math/random]
       (lang ["//." synthesis])
       test)
  (luxc (lang [".L" host]))
  (test/luxc common))

(def: (spec run)
  (-> Runner Test)
  (do r.Monad<Random>
    [%bool% r.bool
     %nat% r.nat
     %int% r.int
     %rev% r.rev
     %frac% r.frac
     %text% (r.ascii +5)]
    (`` ($_ seq
            (~~ (do-template [<desc> <type> <synthesis> <sample> <test>]
                  [(test (format "Can translate " <desc> ".")
                         (|> (run (<synthesis> <sample>))
                             (case> (#e.Success valueT)
                                    (<test> <sample> (:coerce <type> valueT))

                                    (#e.Error error)
                                    (exec (log! error)
                                      false))))]

                  ["bool" Bool //synthesis.bool %bool% bool/=]
                  ["int"  Int  //synthesis.i64  %int%  i/=]
                  ["frac" Frac //synthesis.f64  %frac% f/=]
                  ["text" Text //synthesis.text %text% text/=]))
            ))))

(context: "[JVM] Primitives."
  (<| (times +100)
      (spec run-jvm)))

## (context: "[JS] Primitives."
##   (<| (times +100)
##       (spec run-js)))

## (context: "[Lua] Primitives."
##   (<| (times +100)
##       (spec run-lua)))

## (context: "[Ruby] Primitives."
##   (<| (times +100)
##       (spec run-ruby)))

## (context: "[Python] Primitives."
##   (<| (times +100)
##       (spec run-python)))

## (context: "[R] Primitives."
##   (<| (times +100)
##       (spec run-r)))

## (context: "[Scheme] Primitives."
##   (<| (times +100)
##       (spec run-scheme)))

## (context: "[Common Lisp] Primitives."
##   (<| (times +100)
##       (spec run-common-lisp)))

## (context: "[PHP] Primitives."
##   (<| (times +100)
##       (spec run-php)))