From 3b35f97b07d3a6b439544097fe36628619f95d4f Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Change way macros are invoked, add a bunch of tests --- tests/example_include.smp | 2 +- tests/macro_processor.rs | 55 +++++++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/example_include.smp b/tests/example_include.smp index ce45d39..f38b21f 100644 --- a/tests/example_include.smp +++ b/tests/example_include.smp @@ -1 +1 @@ -define(SMP)DNL +define(SMP)SNNL diff --git a/tests/macro_processor.rs b/tests/macro_processor.rs index 0c3651c..2f54961 100644 --- a/tests/macro_processor.rs +++ b/tests/macro_processor.rs @@ -53,7 +53,7 @@ fn test_smp_define_2() { fn test_smp_dnl_1() { assert_eq!( run_macro_processor( -"DNL +"SNNL test"), "test", @@ -64,7 +64,7 @@ test"), fn test_smp_dnl_2() { assert_eq!( run_macro_processor( -"DNL +"SNNL test"), "test", @@ -75,8 +75,8 @@ test"), fn test_smp_dnl_3() { assert_eq!( run_macro_processor( -"define(MAC1, test)DNL -MAC1 DNL +"define(MAC1, test)SNNL +MAC1 SNNL test"), "test test", @@ -96,7 +96,7 @@ fn test_smp_ifdef_0() { fn test_smp_ifdef_1() { assert_eq!( run_macro_processor( -"define(MAC1, test)DNL +"define(MAC1, test)SNNL ifdef(MAC1, MAC1_ISDEF) ifdef(MAC2, MAC2_ISDEF, MAC2_ISNDEF)"), @@ -140,7 +140,7 @@ fn test_smp_ifndef_1() { fn test_smp_ifndef_2() { assert_eq!( run_macro_processor( -"define(MAC, test)DNL +"define(MAC, test)SNNL ifndef(MAC, MAC_ISNDEF, MAC_ISDEF)"), "MAC_ISDEF", @@ -151,7 +151,7 @@ ifndef(MAC, MAC_ISNDEF, MAC_ISDEF)"), fn test_smp_ifndef_3() { assert_eq!( run_macro_processor( -"define(MAC, test)DNL +"define(MAC, test)SNNL ifndef(MAC, MAC_ISNDEF)"), "", @@ -159,7 +159,7 @@ ifndef(MAC, MAC_ISNDEF)"), } #[test] -fn test_include_1() { +fn test_smp_include_1() { assert_eq!( run_macro_processor( "include(tests/example_include.smp)"), @@ -169,10 +169,10 @@ fn test_include_1() { } #[test] -fn test_include_2() { +fn test_smp_include_2() { assert_eq!( run_macro_processor( -"include(tests/example_include.smp)DNL +"include(tests/example_include.smp)SNNL ifdef(SMP, SMP_ISDEF, SMP_ISNDEF)"), "SMP_ISDEF", @@ -180,7 +180,7 @@ ifdef(SMP, SMP_ISDEF, SMP_ISNDEF)"), } #[test] -fn test_ifeq_1() { +fn test_smp_ifeq_1() { assert_eq!( run_macro_processor("ifeq(a, a, true, false)"), "true", @@ -188,7 +188,7 @@ fn test_ifeq_1() { } #[test] -fn test_ifeq_2() { +fn test_smp_ifeq_2() { assert_eq!( run_macro_processor("ifeq(a, b, true, false)"), "false", @@ -196,7 +196,7 @@ fn test_ifeq_2() { } #[test] -fn test_ifeq_3() { +fn test_smp_ifeq_3() { assert_eq!( run_macro_processor("ifeq(a, a, true)"), "true", @@ -204,7 +204,7 @@ fn test_ifeq_3() { } #[test] -fn test_ifeq_4() { +fn test_smp_ifeq_4() { assert_eq!( run_macro_processor("ifeq(a, b, true)"), "", @@ -212,7 +212,7 @@ fn test_ifeq_4() { } #[test] -fn test_ifneq_1() { +fn test_smp_ifneq_1() { assert_eq!( run_macro_processor("ifneq(a, a, true, false)"), "false", @@ -220,7 +220,7 @@ fn test_ifneq_1() { } #[test] -fn test_ifneq_2() { +fn test_smp_ifneq_2() { assert_eq!( run_macro_processor("ifneq(a, b, true, false)"), "true", @@ -228,7 +228,7 @@ fn test_ifneq_2() { } #[test] -fn test_ifneq_3() { +fn test_smp_ifneq_3() { assert_eq!( run_macro_processor("ifneq(a, a, true)"), "", @@ -236,9 +236,28 @@ fn test_ifneq_3() { } #[test] -fn test_ifneq_4() { +fn test_smp_ifneq_4() { assert_eq!( run_macro_processor("ifneq(a, b, true)"), "true", ); } + +#[test] +fn test_smp_shell_1() { + assert_eq!( + run_macro_processor("shell(printf test)"), + "test", + ); +} + +#[test] +fn test_smp_expr_1() { + assert_eq!( + run_macro_processor("expr(1, +, 1)"), + "2 +", + ); +} + + -- cgit v1.2.3