From f6b1cd530a52ddba4063aa4a3d485c1b6bbaebbd Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 22 Aug 2023 12:43:13 -0400 Subject: [PATCH] Implement assert and assert_equal --- src/macros/logic.rs | 8 +++++--- tests/logic.rs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/macros/logic.rs b/src/macros/logic.rs index 3053e40..cb9d855 100644 --- a/src/macros/logic.rs +++ b/src/macros/logic.rs @@ -9,7 +9,10 @@ impl Macro for Assert { identifier: "assert", description: "Panic if a boolean is false.", group: "test", - inputs: vec![], + inputs: vec![ + ValueType::Boolean, + ValueType::Function + ], } } @@ -33,7 +36,7 @@ impl Macro for AssertEqual { identifier: "assert_equal", description: "Panic if two values do not match.", group: "test", - inputs: vec![], + inputs: vec![ValueType::List(vec![ValueType::Any, ValueType::Any])], } } @@ -42,7 +45,6 @@ impl Macro for AssertEqual { if arguments[0] == arguments[1] { Ok(Value::Empty) - } else { Err(Error::AssertEqualFailed { expected: arguments[0].clone(), actual: arguments[1].clone() }) } diff --git a/tests/logic.rs b/tests/logic.rs index 9ad3f62..6eef79c 100644 --- a/tests/logic.rs +++ b/tests/logic.rs @@ -8,8 +8,8 @@ fn assert() { #[test] fn assert_equal() { - eval("assert_eq(true, true)").unwrap(); - eval("assert_eq(true, false)").unwrap_err(); + eval("assert_equal(true, true)").unwrap(); + eval("assert_equal(true, false)").unwrap_err(); } #[test]