From 3035c35f3de47a132d2d760c041a723236ced91c Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Mon, 23 Sep 2024 14:40:31 +0200 Subject: Add property for evaluating numbers --- rust/src/lambda.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'rust/src/lambda.rs') diff --git a/rust/src/lambda.rs b/rust/src/lambda.rs index a24b031..3c1c8b6 100644 --- a/rust/src/lambda.rs +++ b/rust/src/lambda.rs @@ -23,18 +23,22 @@ impl Display for Value { } } -fn interpret(_arg: &str) -> Value { - Value::Num(1) +fn interpret(arg: &str) -> Value { + Value::Num(arg.parse().unwrap()) } #[cfg(test)] mod tests { use super::interpret; use super::Value::Num; + // Bring the macros and other important things into scope. + use proptest::prelude::*; - #[test] - fn it_works() { - let result = interpret("1"); - assert_eq!(Num(1), result); + proptest! { + #[test] + fn interpret_integer_as_number(i in -1000i32..1000) { + let result = interpret(&i.to_string()); + assert_eq!(Num(i), result); + } } } -- cgit v1.2.3