diff options
| -rw-r--r-- | rust/src/lambda.rs | 7 | ||||
| -rw-r--r-- | rust/src/web.rs | 14 |
2 files changed, 20 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; diff --git a/rust/src/web.rs b/rust/src/web.rs index 3d9fcda..420d72c 100644 --- a/rust/src/web.rs +++ b/rust/src/web.rs @@ -448,6 +448,20 @@ mod app_tests { } #[test] + async fn client_generates_lambda_terms_at_level_6() { + let mut client = client(); + client.grade = 6; + + let (input, _) = client.generate_expr(); + + let parsed = parse(&input); + match &parsed[..] { + [Value::Lam(_, _)] => (), + _ => panic!("Expected symbol, got {:?}", parsed), + } + } + + #[test] async fn client_increases_grade_on_successful_test() { let mut client = client(); let expected = "1".to_string(); |
