tests: Make tests/vector.test compatible with Guile.

* mes/module/mes/type-0.mes (unspecified?): New function.
* tests/vector.test (make-vector): Use it to test equality rather than
rely on string comparison.
This commit is contained in:
Ekaitz 2023-08-24 19:54:06 +02:00 committed by Janneke Nieuwenhuizen
parent 294d8a9737
commit 721a06fc0b
2 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,7 @@
;;; GNU Mes --- Maxwell Equations of Software
;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2023 Ekaitz Zarraga <ekaitz@elenq.tech>
;;;
;;; This file is part of GNU Mes.
;;;
@ -76,6 +77,9 @@
(define (port? x)
(eq? (core:type x) <cell:port>))
(define (unspecified? x)
(eq? (if #f #f) x))
(define (procedure? p)
(and (or (builtin? p)
(and (pair? p) (eq? (car p) 'lambda))

View File

@ -7,6 +7,7 @@ exec ${MES-bin/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests
;;; GNU Mes --- Maxwell Equations of Software
;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2023 Ekaitz Zarraga <ekaitz@elenq.tech>
;;;
;;; This file is part of GNU Mes.
;;;
@ -39,7 +40,11 @@ exec ${MES-bin/mes} --no-auto-compile -L ${0%/*} -L module -C module -e '(tests
(pass-if "vector?" (vector? #(1 2 c)))
(pass-if "vector-length" (seq? (vector-length #(1)) 1))
(pass-if "make-vector" (sequal? (make-vector 3) #(*unspecified* *unspecified* *unspecified*)))
(pass-if "make-vector" (let ((v (make-vector 3)))
(and (= 3 (vector-length v))
(unspecified? (vector-ref v 0))
(unspecified? (vector-ref v 1))
(unspecified? (vector-ref v 2)))))
(pass-if "make-vector 1" (sequal? (make-vector 3 0) #(0 0 0)))
(pass-if "vector-ref" (seq? (vector-ref #(0 1) 1) 1))