aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/parser/synthesis.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/control/parser/synthesis.lux')
-rw-r--r--stdlib/source/test/lux/control/parser/synthesis.lux74
1 files changed, 38 insertions, 36 deletions
diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux
index 62a78cd0e..97d6934ed 100644
--- a/stdlib/source/test/lux/control/parser/synthesis.lux
+++ b/stdlib/source/test/lux/control/parser/synthesis.lux
@@ -13,6 +13,8 @@
["[0]" text]
[collection
["[0]" list ("[1]#[0]" functor)]]]
+ [macro
+ ["^" pattern]]
[math
["[0]" random {"+" Random}]
[number
@@ -68,14 +70,14 @@
($_ _.and
(_.cover [<query>]
(|> (/.result <query> (list (<synthesis> expected)))
- (!expect (^multi {try.#Success actual}
- (# <equivalence> = expected actual)))))
+ (!expect (^.multi {try.#Success actual}
+ (# <equivalence> = expected actual)))))
(_.cover [<check>]
(and (|> (/.result (<check> expected) (list (<synthesis> expected)))
(!expect {try.#Success _}))
(|> (/.result (<check> expected) (list (<synthesis> dummy)))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.cannot_parse error))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.cannot_parse error))))))
))]
[/.bit /.bit! random.bit synthesis.bit bit.equivalence]
@@ -102,15 +104,15 @@
(synthesis.i64 expected_i64)
(synthesis.f64 expected_f64)
(synthesis.text expected_text)))))
- (!expect (^multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]}
- (and (# bit.equivalence = expected_bit actual_bit)
- (# i64.equivalence = expected_i64 actual_i64)
- (# frac.equivalence = expected_f64 actual_f64)
- (# text.equivalence = expected_text actual_text)))))
+ (!expect (^.multi {try.#Success [actual_bit actual_i64 actual_f64 actual_text]}
+ (and (# bit.equivalence = expected_bit actual_bit)
+ (# i64.equivalence = expected_i64 actual_i64)
+ (# frac.equivalence = expected_f64 actual_f64)
+ (# text.equivalence = expected_text actual_text)))))
(|> (/.result (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text))
(list (synthesis.text expected_text)))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.cannot_parse error)))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.cannot_parse error)))))))
(do [! random.monad]
[arity random.nat
expected_environment ..random_environment
@@ -118,15 +120,15 @@
(_.cover [/.function]
(and (|> (/.result (/.function arity /.text)
(list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
- (!expect (^multi {try.#Success [actual_environment actual_body]}
- (and (# (list.equivalence synthesis.equivalence) =
- expected_environment
- actual_environment)
- (# text.equivalence = expected_body actual_body)))))
+ (!expect (^.multi {try.#Success [actual_environment actual_body]}
+ (and (# (list.equivalence synthesis.equivalence) =
+ expected_environment
+ actual_environment)
+ (# text.equivalence = expected_body actual_body)))))
(|> (/.result (/.function arity /.text)
(list (synthesis.text expected_body)))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.cannot_parse error)))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.cannot_parse error)))))))
(do [! random.monad]
[arity random.nat
expected_environment ..random_environment
@@ -134,8 +136,8 @@
(_.cover [/.wrong_arity]
(|> (/.result (/.function (++ arity) /.text)
(list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)])))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.wrong_arity error))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.wrong_arity error))))))
(do [! random.monad]
[arity (# ! each (|>> (n.% 10) ++) random.nat)
expected_offset random.nat
@@ -146,16 +148,16 @@
(list (synthesis.loop/scope [expected_offset
(list#each (|>> synthesis.bit) expected_inits)
(synthesis.text expected_body)])))
- (!expect (^multi {try.#Success [actual_offset actual_inits actual_body]}
- (and (# n.equivalence = expected_offset actual_offset)
- (# (list.equivalence bit.equivalence) =
- expected_inits
- actual_inits)
- (# text.equivalence = expected_body actual_body)))))
+ (!expect (^.multi {try.#Success [actual_offset actual_inits actual_body]}
+ (and (# n.equivalence = expected_offset actual_offset)
+ (# (list.equivalence bit.equivalence) =
+ expected_inits
+ actual_inits)
+ (# text.equivalence = expected_body actual_body)))))
(|> (/.result (/.loop (<>.many /.bit) /.text)
(list (synthesis.text expected_body)))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.cannot_parse error)))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.cannot_parse error)))))))
))
(def: .public test
@@ -167,26 +169,26 @@
[expected (# ! each (|>> synthesis.i64) random.i64)]
(_.cover [/.result /.any]
(|> (/.result /.any (list expected))
- (!expect (^multi {try.#Success actual}
- (# synthesis.equivalence = expected actual))))))
+ (!expect (^.multi {try.#Success actual}
+ (# synthesis.equivalence = expected actual))))))
(_.cover [/.empty_input]
(|> (/.result /.any (list))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.empty_input error)))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.empty_input error)))))
(do [! random.monad]
[expected (# ! each (|>> synthesis.i64) random.i64)]
(_.cover [/.unconsumed_input]
(|> (/.result /.any (list expected expected))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.unconsumed_input error))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.unconsumed_input error))))))
(do [! random.monad]
[dummy (# ! each (|>> synthesis.i64) random.i64)]
(_.cover [/.end! /.expected_empty_input]
(and (|> (/.result /.end! (list))
(!expect {try.#Success _}))
(|> (/.result /.end! (list dummy))
- (!expect (^multi {try.#Failure error}
- (exception.match? /.expected_empty_input error)))))))
+ (!expect (^.multi {try.#Failure error}
+ (exception.match? /.expected_empty_input error)))))))
(do [! random.monad]
[dummy (# ! each (|>> synthesis.i64) random.i64)]
(_.cover [/.end?]