commit 12792d101db190151dd8d065027ad89c3f3e5ae3
parent 28d528469559a6dbc6b6dfdf378ff5e917d3e6f0
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Sun, 16 May 2021 10:58:00 +0100
Added invalid source code tests to asma-test.sh
Diffstat:
1 file changed, 35 insertions(+), 0 deletions(-)
diff --git a/etc/asma-test.sh b/etc/asma-test.sh
@@ -20,6 +20,15 @@ EOD
sed -ne '/%asma-IF-ERROR/,$p' ../projects/software/asma.usm
}
+expect_failure() {
+ cat > 'in.usm'
+ if ../bin/debugger asma.rom > asma.log 2>/dev/null || ! grep -qF "${1}" asma.log; then
+ echo "error: asma didn't report error ${1} in faulty code"
+ tail asma.log
+ exit 1
+ fi
+}
+
echo 'Assembling asma with uxnasm'
build_asma > asma.usm
../bin/uxnasm asma.usm asma.rom > uxnasm.log
@@ -44,5 +53,31 @@ find ../projects -type f -name '*.usm' -not -name 'blank.usm' | sort | while rea
diff -u "uxnasm-${BN}.hex" "asma-${BN}.hex"
done
+expect_failure 'Invalid hexadecimal: $defg' <<'EOD'
+|1000 $defg
+EOD
+expect_failure 'Invalid hexadecimal: #defg' <<'EOD'
+|1000 #defg
+EOD
+expect_failure 'Address not in zero page: .hello' <<'EOD'
+|1000 @hello
+ .hello
+EOD
+expect_failure 'Address outside range: ,hello' <<'EOD'
+|1000 @hello
+|2000 ,hello
+EOD
+expect_failure 'Label not found: hello' <<'EOD'
+hello
+EOD
+expect_failure 'Macro already exists: %abc' <<'EOD'
+%abc { def }
+%abc { ghi }
+EOD
+expect_failure 'Memory overwrite: SUB' <<'EOD'
+|2000 ADD
+|1000 SUB
+EOD
+
echo 'All OK'