mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-30 00:40:20 +02:00
Fix tests that assumed little endian.
* test-suite/tests/asm-to-bytecode.test (u32->u8-list): New procedure. ("compiler")[(load-program 3 2 1 0 () 3 #f (make-int8 3) (return)), (load-program 3 2 1 0 () 3 (load-program 3 2 1 0 ...))]: Make these tests work on hosts whose endianness is not little endian.
This commit is contained in:
parent
c4b681fdac
commit
44362a1086
1 changed files with 30 additions and 13 deletions
|
@ -15,6 +15,7 @@
|
|||
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
(define-module (test-suite tests asm-to-bytecode)
|
||||
#:use-module (rnrs bytevector)
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module (system vm instruction)
|
||||
#:use-module (language assembly compile-bytecode))
|
||||
|
@ -45,6 +46,14 @@
|
|||
(lambda ()
|
||||
(equal? v y)))))
|
||||
|
||||
(define (u32->u8-list x)
|
||||
;; Return a 4 uint8 list corresponding to the host's native representation
|
||||
;; of X, a uint32.
|
||||
(let ((bv (make-bytevector 4)))
|
||||
(bytevector-u32-native-set! bv 0 x)
|
||||
(bytevector->u8-list bv)))
|
||||
|
||||
|
||||
(with-test-prefix "compiler"
|
||||
(with-test-prefix "asm-to-bytecode"
|
||||
|
||||
|
@ -75,22 +84,30 @@
|
|||
(comp-test '(load-keyword "qux")
|
||||
(vector 'load-keyword 0 0 3 (char->integer #\q) (char->integer #\u)
|
||||
(char->integer #\x)))
|
||||
|
||||
;; fixme: little-endian test.
|
||||
(comp-test '(load-program 3 2 1 0 () 3 #f (make-int8 3) (return))
|
||||
(vector 'load-program 3 2 1 0 3 0 0 0 0 0 0 0
|
||||
(instruction->opcode 'make-int8) 3
|
||||
(instruction->opcode 'return)))
|
||||
|
||||
;; fixme: little-endian test.
|
||||
(comp-test '(load-program 3 2 1 0 () 3 #f (make-int8 3) (return))
|
||||
(list->vector
|
||||
`(load-program
|
||||
3 2 1 0 ;; nargs, nrest, nlocs, nexts
|
||||
,@(u32->u8-list 3) ;; len
|
||||
,@(u32->u8-list 0) ;; metalen
|
||||
make-int8 3
|
||||
return)))
|
||||
|
||||
(comp-test '(load-program 3 2 1 0 () 3
|
||||
(load-program 3 2 1 0 () 3
|
||||
#f
|
||||
(make-int8 3) (return))
|
||||
(make-int8 3) (return))
|
||||
(vector 'load-program 3 2 1 0 3 0 0 0 (+ 3 12) 0 0 0
|
||||
(instruction->opcode 'make-int8) 3
|
||||
(instruction->opcode 'return)
|
||||
3 2 1 0 3 0 0 0 0 0 0 0
|
||||
(instruction->opcode 'make-int8) 3
|
||||
(instruction->opcode 'return)))))
|
||||
(list->vector
|
||||
`(load-program
|
||||
3 2 1 0 ;; nargs, nrest, nlocs, nexts
|
||||
,@(u32->u8-list 3) ;; len
|
||||
,@(u32->u8-list (+ 3 12)) ;; metalen
|
||||
make-int8 3
|
||||
return
|
||||
3 2 1 0 ;; nargs, nrest, nlocs, nexts
|
||||
,@(u32->u8-list 3) ;; len
|
||||
,@(u32->u8-list 0) ;; metalen
|
||||
make-int8 3
|
||||
return)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue