summaryrefslogtreecommitdiff
path: root/rust/src/lambda.rs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2024-10-09 15:55:14 +0200
committerArnaud Bailly <arnaud@pankzsoft.com>2024-10-09 15:55:14 +0200
commitc8d286239ef0d14a985cdcc26e0eda57098a5db1 (patch)
treed1f9d4cd73e43b60000901ed5ccbc9b1a3922fb5 /rust/src/lambda.rs
parent318f2008e708ea8fc2fde69525fd8ef530e68cc7 (diff)
downloadlambda-nantes-c8d286239ef0d14a985cdcc26e0eda57098a5db1.tar.gz
Generate multiple expressions
Diffstat (limited to 'rust/src/lambda.rs')
-rw-r--r--rust/src/lambda.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/rust/src/lambda.rs b/rust/src/lambda.rs
index 8ac3e46..4027a62 100644
--- a/rust/src/lambda.rs
+++ b/rust/src/lambda.rs
@@ -117,15 +117,23 @@ pub fn generate_expr(size: u32, runner: &mut TestRunner) -> Value {
6 => simple_lambda().new_tree(runner).unwrap().current(),
7 => app_to_lambda().new_tree(runner).unwrap().current(),
8 => multi_app().new_tree(runner).unwrap().current(),
- 9 => any::<u32>()
+ _ => any::<u32>()
.prop_flat_map(gen_terms)
.new_tree(runner)
.unwrap()
.current(),
- _ => todo!(),
}
}
+pub fn generate_exprs(size: u32, runner: &mut TestRunner) -> Vec<Value> {
+ let sz = (0..size).new_tree(runner).unwrap().current();
+ (0..sz)
+ .collect::<Vec<_>>()
+ .into_iter()
+ .map(|_| generate_expr(size, runner))
+ .collect()
+}
+
fn simple_app() -> impl Strategy<Value = Value> {
let leaf = prop_oneof![any_num(), any_sym()];
(leaf.clone(), leaf.clone()).prop_map(|(l, r)| Value::App(Box::new(l), Box::new(r)))