summaryrefslogtreecommitdiff
path: root/t/parse.lisp
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-16 16:37:18 -0400
committerbd <bdunahu@operationnull.com>2025-04-16 16:37:18 -0400
commit768ebe5c796d85d0262260c9a0b1f7aec28b8844 (patch)
treeb2a3f2a7539aa494019ebc7c14be83b68aaad805 /t/parse.lisp
parent4195307803b49966831c3646e059088c3087f489 (diff)
Let displacement for JAL+JMP be the absolute file position of label
Diffstat (limited to 't/parse.lisp')
-rw-r--r--t/parse.lisp18
1 files changed, 15 insertions, 3 deletions
diff --git a/t/parse.lisp b/t/parse.lisp
index 9e07dd5..29c313d 100644
--- a/t/parse.lisp
+++ b/t/parse.lisp
@@ -4,8 +4,17 @@
:description "Test functions exported from the parser."
:in all-tests)
+(defmacro expect-parse-error (body)
+ `(handler-case
+ (progn ,body
+ (fail))
+ (esrap::parse-error ())))
+
;;; these tests are not exhaustive, and are meant to test basic functionality
;;; under correct circumstances.
+;;; TODO add negative test cases
+;;; TODO undesirably, these tests are setup in a way where the previous tests
+;;; affect the succeeding ones (line labels)
(in-suite parse-tests)
@@ -43,7 +52,7 @@
'(emit::p
(emit::d)
(emit::x
- (emit::j "JMP" (emit::l "FOO" 7) (emit::rr 0))
+ (emit::j "JMP" (emit::rr 0) (emit::l "FOO"))
(emit::j "JRL" (emit::rr 0) (emit::l "FOO" 8))
(emit::j "RET" (emit::rr 0) 0)
(emit::j "PUSH" (emit::rr 5) 0)))
@@ -73,7 +82,7 @@
'(emit::p
(emit::d)
(emit::x
- (emit::j "JMP" (emit::l "FOO" 14) (emit::rr 0))
+ (emit::j "JMP" (emit::rr 0) (emit::l "FOO"))
(emit::j "JRL" (emit::rr 0) (emit::l "FOO" 15))
(emit::j "PUSH" (emit::rr 5) 0)))
(esrap:parse 'parse:str->ast (format nil ".DATA~%~%.TEXT~t~%JMP FOO~t
@@ -84,13 +93,16 @@ JRL FOO~t~%PUSH $5~%")))))
'(emit::p
(emit::d)
(emit::x
- (emit::j "JMP" (emit::l "FOO" 17) (emit::rr 0))
+ (emit::j "JMP" (emit::rr 0) (emit::l "FOO"))
(emit::j "JRL" (emit::rr 0) (emit::l "FOO" 18))
(emit::j "PUSH" (emit::rr 5) 0)))
(esrap:parse 'parse:str->ast (format nil ".DATA~%.TEXT;; dot dot dot
~tJMP FOO ;; this does things
~tJRL FOO~%~tPUSH $5~%")))))
+(test esrap-instr-bad-not
+ (expect-parse-error (esrap:parse 'parse:str->ast (format nil ".DATA~%.TEXT~%~tNOT $5 $5 $5~%"))))
+
(test esrap-data-singleton
(is (equal
'(emit::p