summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud.bailly@iohk.io>2024-09-23 14:40:31 +0200
committerArnaud Bailly <arnaud.bailly@iohk.io>2024-09-23 15:07:31 +0200
commit3035c35f3de47a132d2d760c041a723236ced91c (patch)
treefc83c62b2c731325cabcf2dab68ec48510015ba6 /rust/src
parentde98bfc28feebfe112a378017c73d0e20dfb2937 (diff)
downloadlambda-nantes-3035c35f3de47a132d2d760c041a723236ced91c.tar.gz
Add property for evaluating numbers
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/lambda.rs16
1 files changed, 10 insertions, 6 deletions
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);
+ }
}
}