From 12792d101db190151dd8d065027ad89c3f3e5ae3 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Sun, 16 May 2021 10:58:00 +0100 Subject: [PATCH] Added invalid source code tests to asma-test.sh --- etc/asma-test.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/etc/asma-test.sh b/etc/asma-test.sh index 7fdecc0..b014d83 100755 --- 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'