scm-to-vm/tests.scm
2025-01-06 10:36:17 -06:00

22 lines
551 B
Scheme
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(use-modules (d- test))
;;; VM tests
(use-modules (scmvm vm)
(rnrs bytevectors)
(rnrs io ports))
(define adder-program
#vu8(#x01 1 0 0 0 ; Push value "1"
#x01 2 0 0 0 ; Push value "2"
#x05 ; Perform "+"
#x03 1 0 0 0 ; Store the value to memory address 1
))
(define-test-suite "VM"
(define-test "adder"
(define my-vm (make-vm))
(define my-program (open-bytevector-input-port adder-program))
(run-program my-vm my-program)
(assert-equal 3 (vm-memory-ref my-vm 1))))