mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-31 09:20:23 +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
|
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
(define-module (test-suite tests asm-to-bytecode)
|
(define-module (test-suite tests asm-to-bytecode)
|
||||||
|
#:use-module (rnrs bytevector)
|
||||||
#:use-module (test-suite lib)
|
#:use-module (test-suite lib)
|
||||||
#:use-module (system vm instruction)
|
#:use-module (system vm instruction)
|
||||||
#:use-module (language assembly compile-bytecode))
|
#:use-module (language assembly compile-bytecode))
|
||||||
|
@ -45,6 +46,14 @@
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(equal? v y)))))
|
(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 "compiler"
|
||||||
(with-test-prefix "asm-to-bytecode"
|
(with-test-prefix "asm-to-bytecode"
|
||||||
|
|
||||||
|
@ -75,22 +84,30 @@
|
||||||
(comp-test '(load-keyword "qux")
|
(comp-test '(load-keyword "qux")
|
||||||
(vector 'load-keyword 0 0 3 (char->integer #\q) (char->integer #\u)
|
(vector 'load-keyword 0 0 3 (char->integer #\q) (char->integer #\u)
|
||||||
(char->integer #\x)))
|
(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
|
(comp-test '(load-program 3 2 1 0 () 3
|
||||||
(load-program 3 2 1 0 () 3
|
(load-program 3 2 1 0 () 3
|
||||||
#f
|
#f
|
||||||
(make-int8 3) (return))
|
(make-int8 3) (return))
|
||||||
(make-int8 3) (return))
|
(make-int8 3) (return))
|
||||||
(vector 'load-program 3 2 1 0 3 0 0 0 (+ 3 12) 0 0 0
|
(list->vector
|
||||||
(instruction->opcode 'make-int8) 3
|
`(load-program
|
||||||
(instruction->opcode 'return)
|
3 2 1 0 ;; nargs, nrest, nlocs, nexts
|
||||||
3 2 1 0 3 0 0 0 0 0 0 0
|
,@(u32->u8-list 3) ;; len
|
||||||
(instruction->opcode 'make-int8) 3
|
,@(u32->u8-list (+ 3 12)) ;; metalen
|
||||||
(instruction->opcode 'return)))))
|
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