Browse code

Added invalid source code tests to asma-test.sh

Andrew Alderwick authored on 16/05/2021 09:58:00
Showing 1 changed files
... ...
@@ -20,6 +20,15 @@ EOD
20 20
 	sed -ne '/%asma-IF-ERROR/,$p' ../projects/software/asma.usm
21 21
 }
22 22
 
23
+expect_failure() {
24
+    cat > 'in.usm'
25
+    if ../bin/debugger asma.rom > asma.log 2>/dev/null || ! grep -qF "${1}" asma.log; then
26
+        echo "error: asma didn't report error ${1} in faulty code"
27
+		tail asma.log
28
+        exit 1
29
+    fi
30
+}
31
+
23 32
 echo 'Assembling asma with uxnasm'
24 33
 build_asma > asma.usm
25 34
 ../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
44 53
 
45 54
 	diff -u "uxnasm-${BN}.hex" "asma-${BN}.hex"
46 55
 done
56
+expect_failure 'Invalid hexadecimal: $defg' <<'EOD'
57
+|1000 $defg
58
+EOD
59
+expect_failure 'Invalid hexadecimal: #defg' <<'EOD'
60
+|1000 #defg
61
+EOD
62
+expect_failure 'Address not in zero page: .hello' <<'EOD'
63
+|1000 @hello
64
+	.hello
65
+EOD
66
+expect_failure 'Address outside range: ,hello' <<'EOD'
67
+|1000 @hello
68
+|2000 ,hello
69
+EOD
70
+expect_failure 'Label not found: hello' <<'EOD'
71
+hello
72
+EOD
73
+expect_failure 'Macro already exists: %abc' <<'EOD'
74
+%abc { def }
75
+%abc { ghi }
76
+EOD
77
+expect_failure 'Memory overwrite: SUB' <<'EOD'
78
+|2000 ADD
79
+|1000 SUB
80
+EOD
81
+
47 82
 echo 'All OK'
48 83