diff options
| author | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-09 07:45:10 +0200 |
|---|---|---|
| committer | Arnaud Bailly <arnaud.bailly@iohk.io> | 2024-10-09 07:45:10 +0200 |
| commit | 2ae4f8552b7101e118dc0a46797bc6ba6945a7b1 (patch) | |
| tree | c8eabe0a3673aa67668af24c903635e6a68a5687 /rust/src/lambda.rs | |
| parent | e8ab131a2b54aa4252ccda3261a0a6a2ade6a273 (diff) | |
| download | lambda-nantes-2ae4f8552b7101e118dc0a46797bc6ba6945a7b1.tar.gz | |
Generate simple lambda forms
Diffstat (limited to 'rust/src/lambda.rs')
| -rw-r--r-- | rust/src/lambda.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rust/src/lambda.rs b/rust/src/lambda.rs index 406aebf..e6102d8 100644 --- a/rust/src/lambda.rs +++ b/rust/src/lambda.rs @@ -114,6 +114,7 @@ pub fn generate_expr(size: u32, runner: &mut TestRunner) -> Value { 3 => any_sym().new_tree(runner).unwrap().current(), 4 => simple_app().new_tree(runner).unwrap().current(), 5 => nested_simple_app().new_tree(runner).unwrap().current(), + 6 => simple_lambda().new_tree(runner).unwrap().current(), _ => todo!(), } } @@ -128,7 +129,7 @@ fn any_num() -> impl Strategy<Value = Value> { } fn nested_simple_app() -> impl Strategy<Value = Value> { - let leaf = prop_oneof![any_num(), any_sym()]; + let leaf = prop_oneof![any_num(), ascii_identifier().prop_map(Value::Sym)]; leaf.prop_recursive(4, 128, 5, move |inner| { (inner.clone(), inner.clone()).prop_map(|(l, r)| Value::App(Box::new(l), Box::new(r))) }) @@ -138,6 +139,10 @@ fn any_sym() -> impl Strategy<Value = Value> { identifier().prop_map(Value::Sym) } +fn simple_lambda() -> impl Strategy<Value = Value> { + (ascii_identifier(), nested_simple_app()).prop_map(|(v, b)| Value::Lam(v, Box::new(b))) +} + #[cfg(test)] mod lambda_test { use crate::parser::parse; |
