remove all mentions of "external" from the compiler and related code
[bpt/guile.git] / test-suite / tests / asm-to-bytecode.test
index 2af3152..d819a3b 100644 (file)
@@ -3,7 +3,7 @@
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
-;;;; version 2.1 of the License, or (at your option) any later version.
+;;;; version 3 of the License, or (at your option) any later version.
 ;;;; 
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -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))
               (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)))
+
+\f
 (with-test-prefix "compiler"
   (with-test-prefix "asm-to-bytecode"
 
     (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
-                              (load-program 3 2 1 0 () 3
+    (comp-test '(load-program 3 2 1 () 3 #f (make-int8 3) (return))
+               (list->vector
+                `(load-program
+                  3 2 1 0            ;; nargs, nrest, nlocs, unused
+                  ,@(u32->u8-list 3) ;; len
+                  ,@(u32->u8-list 0) ;; metalen
+                  make-int8 3
+                  return)))
+
+    (comp-test '(load-program 3 2 1 () 3
+                              (load-program 3 2 1 () 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, unused
+                  ,@(u32->u8-list 3)        ;; len
+                  ,@(u32->u8-list (+ 3 12)) ;; metalen
+                  make-int8 3
+                  return
+                  3 2 1 0                   ;; nargs, nrest, nlocs, unused
+                  ,@(u32->u8-list 3)        ;; len
+                  ,@(u32->u8-list 0)        ;; metalen
+                  make-int8 3
+                  return)))))