From 74770a7a31cea501a9cb638cf6f4f1b27f1bf97f Mon Sep 17 00:00:00 2001 From: bad Date: Sun, 3 Apr 2022 21:54:39 +0200 Subject: [PATCH] Add basic unit tests --- tests/integration_test.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/integration_test.rs diff --git a/tests/integration_test.rs b/tests/integration_test.rs new file mode 100644 index 0000000..7414e26 --- /dev/null +++ b/tests/integration_test.rs @@ -0,0 +1,17 @@ +use crftng_intrprtrs::run; +use crftng_intrprtrs::interpreter::types; + +#[test] +fn test_one_equality() { + run_check_result_eq_bool("1 == 1", true); + run_check_result_eq_bool("1 >= 1", true); + run_check_result_eq_bool("1 <= 1", true); + run_check_result_eq_bool("1 != 1", false); + run_check_result_eq_bool("1 > 1", false); + run_check_result_eq_bool("1 < 1", false); +} + +fn run_check_result_eq_bool(code: &str, value: bool) { + assert_eq!(run(code).unwrap(), types::Value::Primitive(types::Primitive::Bool(value))) + +}