blob: 2e909dd7e2e4f709c6f7e38e883d560f91e6a413 (
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
|
(;module:
lux
(lux [io]
(control [monad #+ do]
pipe)
(data text/format
["e" error]
[bool "B/" Eq<Bool>]
[text "T/" Eq<Text>])
["r" math/random]
[meta]
test)
(luxc (lang ["ls" synthesis])
[analyser]
[synthesizer]
(generator ["@" expr]
["@;" runtime]
["@;" eval]
["@;" common]))
(test/luxc common))
(context: "Primitives."
(<| (times +100)
(do @
[%bool% r;bool
%nat% r;nat
%int% r;int
%deg% r;deg
%frac% r;frac
%text% (r;text +5)]
(with-expansions
[<tests> (do-template [<desc> <type> <synthesis> <sample> <test>]
[(test (format "Can generate " <desc> ".")
(|> (do meta;Monad<Meta>
[sampleI (@;generate (<synthesis> <sample>))]
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success valueG)
(<test> <sample> (:! <type> valueG))
_
false)))]
["bool" Bool #ls;Bool %bool% B/=]
["nat" Nat #ls;Nat %nat% n.=]
["int" Int #ls;Int %int% i.=]
["deg" Deg #ls;Deg %deg% d.=]
["frac" Frac #ls;Frac %frac% f.=]
["text" Text #ls;Text %text% T/=])]
($_ seq
(test "Can generate unit."
(|> (do meta;Monad<Meta>
[sampleI (@;generate #ls;Unit)]
(@eval;eval sampleI))
(meta;run (init-compiler []))
(case> (#e;Success valueG)
(is @runtime;unit (:! Text valueG))
_
false)))
<tests>
)))))
|