aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/synthesizer/procedure.lux
blob: c659c5e3426317cdaf937a4686ba23fbccfad8dc (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
(;module:
  lux
  (lux [io]
       (control [monad #+ do]
                pipe)
       (data [text "text/" Eq<Text>]
             [product]
             (coll [list]))
       ["r" math/random "r/" Monad<Random>]
       test)
  (luxc (lang ["la" analysis]
              ["ls" synthesis])
        [synthesizer])
  (.. common))

(context: "Procedures"
  (<| (times +100)
      (do @
        [num-args (|> r;nat (:: @ map (n.% +10)))
         nameA (r;text +5)
         argsA (r;list num-args gen-primitive)]
        ($_ seq
            (test "Can synthesize procedure calls."
                  (|> (synthesizer;synthesize (la;procedure nameA argsA))
                      (case> (^ [_ (#;Form (list& [_ (#;Text procedure)] argsS))])
                             (and (text/= nameA procedure)
                                  (list;every? (product;uncurry corresponds?)
                                               (list;zip2 argsA argsS)))
                             
                             _
                             false)))
            ))))