aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorQrius <[email protected]>2025-02-21 12:51:08 +0100
committerQrius <[email protected]>2025-02-21 12:51:11 +0100
commit5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc (patch)
tree748dc9a19cdc3e9910f832d1a7a1ba81acbe22e9 /tests
downloadskaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.tar.gz
skaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.zip
first version of python rewrite
Diffstat (limited to 'tests')
-rw-r--r--tests/example_include.smp1
-rw-r--r--tests/input_files/array_each_17
-rw-r--r--tests/input_files/array_push_15
-rw-r--r--tests/input_files/array_push_25
-rw-r--r--tests/input_files/array_push_38
-rw-r--r--tests/input_files/define_15
-rw-r--r--tests/input_files/define_23
-rw-r--r--tests/input_files/dnl_14
-rw-r--r--tests/input_files/dnl_24
-rw-r--r--tests/input_files/dnl_34
-rw-r--r--tests/input_files/dnl_44
-rw-r--r--tests/input_files/explode_15
-rw-r--r--tests/input_files/explode_26
-rw-r--r--tests/input_files/format_time_13
-rw-r--r--tests/input_files/ifdef_16
-rw-r--r--tests/input_files/ifdef_23
-rw-r--r--tests/input_files/ifdef_33
-rw-r--r--tests/input_files/ifeq_13
-rw-r--r--tests/input_files/ifeq_23
-rw-r--r--tests/input_files/ifeq_33
-rw-r--r--tests/input_files/ifeq_43
-rw-r--r--tests/input_files/ifndef_13
-rw-r--r--tests/input_files/ifndef_24
-rw-r--r--tests/input_files/ifndef_34
-rw-r--r--tests/input_files/ifneq_13
-rw-r--r--tests/input_files/ifneq_23
-rw-r--r--tests/input_files/ifneq_33
-rw-r--r--tests/input_files/ifneq_43
-rw-r--r--tests/input_files/include_13
-rw-r--r--tests/input_files/include_24
-rw-r--r--tests/input_files/markdown_html_15
-rw-r--r--tests/input_files/markdown_html_25
-rw-r--r--tests/input_files/non_macro_html7
-rw-r--r--tests/input_files/shell_13
-rw-r--r--tests/input_files/snnl_14
-rw-r--r--tests/input_files/snnl_24
-rw-r--r--tests/input_files/snnl_35
-rw-r--r--tests/input_files/special_macros_13
-rw-r--r--tests/input_files/whitespace_deleting_13
-rw-r--r--tests/input_files/whitespace_deleting_23
-rwxr-xr-xtests/test_macro_processor.sh43
41 files changed, 203 insertions, 0 deletions
diff --git a/tests/example_include.smp b/tests/example_include.smp
new file mode 100644
index 0000000..f38b21f
--- /dev/null
+++ b/tests/example_include.smp
@@ -0,0 +1 @@
+define(SMP)SNNL
diff --git a/tests/input_files/array_each_1 b/tests/input_files/array_each_1
new file mode 100644
index 0000000..5844d71
--- /dev/null
+++ b/tests/input_files/array_each_1
@@ -0,0 +1,7 @@
+define_array(arr)DNL
+define(item, <span>$0</span>)DNL
+array_push(arr, test)DNL
+array_push(arr, tast)DNL
+array_each(arr, item)
+---
+<span>test</span><span>tast</span>
diff --git a/tests/input_files/array_push_1 b/tests/input_files/array_push_1
new file mode 100644
index 0000000..fb59320
--- /dev/null
+++ b/tests/input_files/array_push_1
@@ -0,0 +1,5 @@
+define_array(arr)DNL
+array_push(arr, test)DNL
+array_size(arr)
+---
+1
diff --git a/tests/input_files/array_push_2 b/tests/input_files/array_push_2
new file mode 100644
index 0000000..3b4d652
--- /dev/null
+++ b/tests/input_files/array_push_2
@@ -0,0 +1,5 @@
+define_array(arr)DNL
+array_push(arr, test, tast, toast)DNL
+array_size(arr)
+---
+3
diff --git a/tests/input_files/array_push_3 b/tests/input_files/array_push_3
new file mode 100644
index 0000000..60417b4
--- /dev/null
+++ b/tests/input_files/array_push_3
@@ -0,0 +1,8 @@
+define_array(arr)DNL
+array_push(arr, test, tast, toast)DNL
+array_size(arr)
+array_push(arr, test, tast, toast)DNL
+array_size(arr)
+---
+3
+6
diff --git a/tests/input_files/define_1 b/tests/input_files/define_1
new file mode 100644
index 0000000..68002ea
--- /dev/null
+++ b/tests/input_files/define_1
@@ -0,0 +1,5 @@
+define(TEMP, testvalue)
+TEMP
+---
+
+testvalue
diff --git a/tests/input_files/define_2 b/tests/input_files/define_2
new file mode 100644
index 0000000..016294a
--- /dev/null
+++ b/tests/input_files/define_2
@@ -0,0 +1,3 @@
+define(TEMP, TEMP2)define(TEMP)ifdef(TEMP2, TEMP2_ISDEF)
+---
+TEMP2_ISDEF
diff --git a/tests/input_files/dnl_1 b/tests/input_files/dnl_1
new file mode 100644
index 0000000..c12bc01
--- /dev/null
+++ b/tests/input_files/dnl_1
@@ -0,0 +1,4 @@
+DNL
+test
+---
+test
diff --git a/tests/input_files/dnl_2 b/tests/input_files/dnl_2
new file mode 100644
index 0000000..356aee9
--- /dev/null
+++ b/tests/input_files/dnl_2
@@ -0,0 +1,4 @@
+DNL ifdef(a, b, c)
+test
+---
+test
diff --git a/tests/input_files/dnl_3 b/tests/input_files/dnl_3
new file mode 100644
index 0000000..356aee9
--- /dev/null
+++ b/tests/input_files/dnl_3
@@ -0,0 +1,4 @@
+DNL ifdef(a, b, c)
+test
+---
+test
diff --git a/tests/input_files/dnl_4 b/tests/input_files/dnl_4
new file mode 100644
index 0000000..67c1c0e
--- /dev/null
+++ b/tests/input_files/dnl_4
@@ -0,0 +1,4 @@
+DNL
+test
+---
+test
diff --git a/tests/input_files/explode_1 b/tests/input_files/explode_1
new file mode 100644
index 0000000..79b70ba
--- /dev/null
+++ b/tests/input_files/explode_1
@@ -0,0 +1,5 @@
+define_array(arr)DNL
+explode(arr, |, a|b|c|d)DNL
+array_size(arr)
+---
+4
diff --git a/tests/input_files/explode_2 b/tests/input_files/explode_2
new file mode 100644
index 0000000..7ef0c08
--- /dev/null
+++ b/tests/input_files/explode_2
@@ -0,0 +1,6 @@
+define_array(arr)DNL
+define(item, $0)DNL
+explode(arr, |, a|b|c|d)DNL
+array_each(arr, item)
+---
+abcd
diff --git a/tests/input_files/format_time_1 b/tests/input_files/format_time_1
new file mode 100644
index 0000000..bd9a097
--- /dev/null
+++ b/tests/input_files/format_time_1
@@ -0,0 +1,3 @@
+format_time(%d %B %Y, 2024-04-04T00:00:00Z)
+---
+04 April 2024
diff --git a/tests/input_files/ifdef_1 b/tests/input_files/ifdef_1
new file mode 100644
index 0000000..a308141
--- /dev/null
+++ b/tests/input_files/ifdef_1
@@ -0,0 +1,6 @@
+define(MAC1, test)SNNL
+ifdef(MAC1, MAC1_ISDEF)
+ifdef(MAC2, MAC2_ISDEF, MAC2_ISNDEF)
+---
+MAC1_ISDEF
+MAC2_ISNDEF
diff --git a/tests/input_files/ifdef_2 b/tests/input_files/ifdef_2
new file mode 100644
index 0000000..ecef66c
--- /dev/null
+++ b/tests/input_files/ifdef_2
@@ -0,0 +1,3 @@
+ifdef(MAC, MAC_ISDEF)
+---
+
diff --git a/tests/input_files/ifdef_3 b/tests/input_files/ifdef_3
new file mode 100644
index 0000000..4867034
--- /dev/null
+++ b/tests/input_files/ifdef_3
@@ -0,0 +1,3 @@
+ifdef(MAC, MAC_ISDEF, MAC_ISNDEF)
+---
+MAC_ISNDEF
diff --git a/tests/input_files/ifeq_1 b/tests/input_files/ifeq_1
new file mode 100644
index 0000000..3e49f68
--- /dev/null
+++ b/tests/input_files/ifeq_1
@@ -0,0 +1,3 @@
+ifeq(a, a, true, false)
+---
+true
diff --git a/tests/input_files/ifeq_2 b/tests/input_files/ifeq_2
new file mode 100644
index 0000000..fe7c0ac
--- /dev/null
+++ b/tests/input_files/ifeq_2
@@ -0,0 +1,3 @@
+ifeq(a, b, true, false)
+---
+false
diff --git a/tests/input_files/ifeq_3 b/tests/input_files/ifeq_3
new file mode 100644
index 0000000..42646b8
--- /dev/null
+++ b/tests/input_files/ifeq_3
@@ -0,0 +1,3 @@
+ifeq(a, a, true)
+---
+true
diff --git a/tests/input_files/ifeq_4 b/tests/input_files/ifeq_4
new file mode 100644
index 0000000..d069530
--- /dev/null
+++ b/tests/input_files/ifeq_4
@@ -0,0 +1,3 @@
+ifeq(a, b, true)
+---
+
diff --git a/tests/input_files/ifndef_1 b/tests/input_files/ifndef_1
new file mode 100644
index 0000000..857204b
--- /dev/null
+++ b/tests/input_files/ifndef_1
@@ -0,0 +1,3 @@
+ifndef(MAC, MAC_ISNDEF)
+---
+MAC_ISNDEF
diff --git a/tests/input_files/ifndef_2 b/tests/input_files/ifndef_2
new file mode 100644
index 0000000..fbe0ba3
--- /dev/null
+++ b/tests/input_files/ifndef_2
@@ -0,0 +1,4 @@
+define(MAC, test)SNNL
+ifndef(MAC, MAC_ISNDEF, MAC_ISDEF)
+---
+MAC_ISDEF
diff --git a/tests/input_files/ifndef_3 b/tests/input_files/ifndef_3
new file mode 100644
index 0000000..82a180d
--- /dev/null
+++ b/tests/input_files/ifndef_3
@@ -0,0 +1,4 @@
+define(MAC, test)SNNL
+ifndef(MAC, MAC_ISNDEF)
+---
+
diff --git a/tests/input_files/ifneq_1 b/tests/input_files/ifneq_1
new file mode 100644
index 0000000..5b443c5
--- /dev/null
+++ b/tests/input_files/ifneq_1
@@ -0,0 +1,3 @@
+ifneq(a, a, true, false)
+---
+false
diff --git a/tests/input_files/ifneq_2 b/tests/input_files/ifneq_2
new file mode 100644
index 0000000..8145e9f
--- /dev/null
+++ b/tests/input_files/ifneq_2
@@ -0,0 +1,3 @@
+ifneq(a, b, true, false)
+---
+true
diff --git a/tests/input_files/ifneq_3 b/tests/input_files/ifneq_3
new file mode 100644
index 0000000..163d871
--- /dev/null
+++ b/tests/input_files/ifneq_3
@@ -0,0 +1,3 @@
+ifneq(a, a, true)
+---
+
diff --git a/tests/input_files/ifneq_4 b/tests/input_files/ifneq_4
new file mode 100644
index 0000000..c93a572
--- /dev/null
+++ b/tests/input_files/ifneq_4
@@ -0,0 +1,3 @@
+ifneq(a, b, true)
+---
+true
diff --git a/tests/input_files/include_1 b/tests/input_files/include_1
new file mode 100644
index 0000000..1621de2
--- /dev/null
+++ b/tests/input_files/include_1
@@ -0,0 +1,3 @@
+include(tests/example_include.smp)
+---
+
diff --git a/tests/input_files/include_2 b/tests/input_files/include_2
new file mode 100644
index 0000000..2714eff
--- /dev/null
+++ b/tests/input_files/include_2
@@ -0,0 +1,4 @@
+include(tests/example_include.smp)SNNL
+ifdef(SMP, SMP_ISDEF, SMP_ISNDEF)
+---
+SMP_ISDEF
diff --git a/tests/input_files/markdown_html_1 b/tests/input_files/markdown_html_1
new file mode 100644
index 0000000..6a9f143
--- /dev/null
+++ b/tests/input_files/markdown_html_1
@@ -0,0 +1,5 @@
+html_from_markdown(%"
+# Test
+"%)
+---
+<h1>Test</h1>
diff --git a/tests/input_files/markdown_html_2 b/tests/input_files/markdown_html_2
new file mode 100644
index 0000000..6a9f143
--- /dev/null
+++ b/tests/input_files/markdown_html_2
@@ -0,0 +1,5 @@
+html_from_markdown(%"
+# Test
+"%)
+---
+<h1>Test</h1>
diff --git a/tests/input_files/non_macro_html b/tests/input_files/non_macro_html
new file mode 100644
index 0000000..6f49b4a
--- /dev/null
+++ b/tests/input_files/non_macro_html
@@ -0,0 +1,7 @@
+<html>
+ <p>This is a <em>test</em></p>
+</html>
+---
+<html>
+ <p>This is a <em>test</em></p>
+</html>
diff --git a/tests/input_files/shell_1 b/tests/input_files/shell_1
new file mode 100644
index 0000000..3eb1f14
--- /dev/null
+++ b/tests/input_files/shell_1
@@ -0,0 +1,3 @@
+shell(printf test)
+---
+test
diff --git a/tests/input_files/snnl_1 b/tests/input_files/snnl_1
new file mode 100644
index 0000000..47a10b9
--- /dev/null
+++ b/tests/input_files/snnl_1
@@ -0,0 +1,4 @@
+SNNL
+test
+---
+test
diff --git a/tests/input_files/snnl_2 b/tests/input_files/snnl_2
new file mode 100644
index 0000000..2fcd0ba
--- /dev/null
+++ b/tests/input_files/snnl_2
@@ -0,0 +1,4 @@
+SNNL
+test
+---
+test
diff --git a/tests/input_files/snnl_3 b/tests/input_files/snnl_3
new file mode 100644
index 0000000..4a7dad7
--- /dev/null
+++ b/tests/input_files/snnl_3
@@ -0,0 +1,5 @@
+define(MAC1, test)SNNL
+MAC1 SNNL
+test
+---
+test test
diff --git a/tests/input_files/special_macros_1 b/tests/input_files/special_macros_1
new file mode 100644
index 0000000..eba505b
--- /dev/null
+++ b/tests/input_files/special_macros_1
@@ -0,0 +1,3 @@
+@test
+---
+@test
diff --git a/tests/input_files/whitespace_deleting_1 b/tests/input_files/whitespace_deleting_1
new file mode 100644
index 0000000..ccda45f
--- /dev/null
+++ b/tests/input_files/whitespace_deleting_1
@@ -0,0 +1,3 @@
+define(a, b) a
+---
+ b
diff --git a/tests/input_files/whitespace_deleting_2 b/tests/input_files/whitespace_deleting_2
new file mode 100644
index 0000000..8777c39
--- /dev/null
+++ b/tests/input_files/whitespace_deleting_2
@@ -0,0 +1,3 @@
+define(a, b) a_
+---
+b
diff --git a/tests/test_macro_processor.sh b/tests/test_macro_processor.sh
new file mode 100755
index 0000000..1a7accd
--- /dev/null
+++ b/tests/test_macro_processor.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+ALL_OUTPUT=0
+
+test () {
+ file_content=$(<tests/input_files/$1)
+ readarray -t sections < <(awk -v RS="---" '{print}' <<< "$file_content")
+ var1=$(echo "$file_content" | awk -v RS="\n---\n" 'NR==1')
+ var2=$(echo "$file_content" | awk -v RS="\n---\n" 'NR==2')
+
+ if [ "$ALL_OUTPUT" -eq 0 ]; then
+ res=$(echo -n "$var1" | smp 2> /dev/null)
+ else
+ res=$(echo -n "$var1" | smp)
+ fi
+ if [ ! "$res" = "$var2" ]; then
+ tput setaf 1
+ echo "$1 NOT OK:"
+ tput setaf 3
+ echo "- Expected --"
+ echo "$var2"
+ tput setaf 1
+ echo "- Result ----"
+ echo "$res"
+ echo "-------------"
+ tput sgr0
+ exit 1
+ else
+ tput setaf 2
+ echo "$1 OK"
+ tput sgr0
+ fi
+}
+
+if [ "$#" -eq 1 ]; then
+ ALL_OUTPUT=1
+ test $1
+else
+ for file in tests/input_files/*; do
+ test "$(basename $file)"
+ done
+fi
+