(import (scheme base) (only (csc testing) test assert-equal) (csc encoding)) (test encode-const (assert-equal '(#xf2 #x3 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff) (encode '((const -10))))) (test encode-add (assert-equal '(#xfc #x3 0 0 0 0 0 0) (encode '(add)))) (test encode-sub (assert-equal '(#x6 #x4 0 0 0 0 0 0) (encode '(sub)))) (test encode-mul (assert-equal '(#x10 #x4 0 0 0 0 0 0) (encode '(mul)))) (test encode-div (assert-equal '(#x1a #x4 0 0 0 0 0 0) (encode '(div)))) (test encode-mod (assert-equal '(#x24 #x4 0 0 0 0 0 0) (encode '(mod)))) (test encode-alloc (assert-equal '(#xda #x7 0 0 0 0 0 0) (encode '(alloc)))) (test encode-peek (assert-equal '(#xe4 #x7 0 0 0 0 0 0 #xa) (encode '((peek 10))))) (test encode-poke (assert-equal '(#xee #x7 0 0 0 0 0 0 #xa) (encode '((poke 10))))) (test encode-peekbyte (assert-equal '(#xf8 #x7 0 0 0 0 0 0) (encode '(peekbyte)))) (test encode-pokebyte (assert-equal '(#x2 #x8 0 0 0 0 0 0) (encode '(pokebyte)))) (test encode-pop (assert-equal '(#xc2 #xb 0 0 0 0 0 0) (encode '(pop)))) (test encode-local (assert-equal '(#xcc #xb 0 0 0 0 0 0 #xa) (encode '((local 10))))) (test encode-if (assert-equal '(#xaa #xf 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff) (encode '((if -10))))) (test encode-call (assert-equal '(#xb4 #xf 0 0 0 0 0 0 #xa) (encode '((call 10))))) (test encode-ret (assert-equal '(#xbe #xf 0 0 0 0 0 0) (encode '(ret)))) (test encode-exit (assert-equal '(#xc8 #xf 0 0 0 0 0 0) (encode '(exit)))) (test encode-putc (assert-equal '(#x92 #x13 0 0 0 0 0 0) (encode '(putc)))) (test encode-getc (assert-equal '(#x9c #x13 0 0 0 0 0 0) (encode '(getc))))