aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/lang/synthesis/procedure.lux
blob: 2263a161625027e7f570f9c5f41cdb9b91c4bd45 (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]
              (synthesis [";S" expression])))
  (.. 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."
                  (|> (expressionS;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)))
            ))))