aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/lang/synthesis/procedure.lux
blob: ab6c9de6f451afdababd41b3eff9c976aca3f125 (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
(.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])
              [".L" extension]))
  (// 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 extensionL.no-syntheses
                                              (la.procedure nameA argsA))
                      (case> (^ [_ (#.Form (list& [_ (#.Text procedure)] argsS))])
                             (and (text/= nameA procedure)
                                  (list.every? (product.uncurry corresponds?)
                                               (list.zip2 argsA argsS)))
                             
                             _
                             #0)))
            ))))