From 721a06fc0b586f7615a7f6c5f78d33223f3fd987 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 24 Aug 2023 19:54:06 +0200 Subject: [PATCH] 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. --- mes/module/mes/type-0.mes | 4 ++++ tests/vector.test | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mes/module/mes/type-0.mes b/mes/module/mes/type-0.mes index beefbf06..5d1af885 100644 --- a/mes/module/mes/type-0.mes +++ b/mes/module/mes/type-0.mes @@ -2,6 +2,7 @@ ;;; GNU Mes --- Maxwell Equations of Software ;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2023 Ekaitz Zarraga ;;; ;;; This file is part of GNU Mes. ;;; @@ -76,6 +77,9 @@ (define (port? x) (eq? (core:type x) )) +(define (unspecified? x) + (eq? (if #f #f) x)) + (define (procedure? p) (and (or (builtin? p) (and (pair? p) (eq? (car p) 'lambda)) diff --git a/tests/vector.test b/tests/vector.test index 0bf8c185..8263b3e4 100755 --- a/tests/vector.test +++ b/tests/vector.test @@ -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 +;;; Copyright © 2023 Ekaitz Zarraga ;;; ;;; 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))