From 16051070722bc433fad92a83c7522837257cf071 Mon Sep 17 00:00:00 2001 From: Kristian Lein-Mathisen Date: Thu, 13 Apr 2017 14:15:07 +0200 Subject: [PATCH] Fix a bug in srfi-4 this correctly uses s8vector-set! for the s8vector-ref's setter Signed-off-by: Peter Bex Conflicts: tests/srfi-4-tests.scm --- NEWS | 2 ++ srfi-4.scm | 2 +- tests/srfi-4-tests.scm | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a107ebb..c61cf58 100644 --- a/NEWS +++ b/NEWS @@ -73,6 +73,8 @@ interrupted by a signal, we now retry (thanks to Joerg Wittenberger). - char-ready? on string ports now also returns #t at EOF, as per R5RS; in other words, it always returns #t (thanks to Moritz Heidkamp) + - Unit srfi-4: Fixed typo that broke SRFI-17 generalised set! syntax + on s8vectors (thanks to Kristian Lein-Mathisen). - Build system - Fixed broken compilation on NetBSD, due to missing _NETBSD_SOURCE. diff --git a/srfi-4.scm b/srfi-4.scm index 0371b9e..3d532d8 100644 --- a/srfi-4.scm +++ b/srfi-4.scm @@ -257,7 +257,7 @@ EOF (let ((len (##core#inline "C_u_i_s8vector_length" x))) (check-range i 0 len 's8vector-ref) (##core#inline "C_u_i_s8vector_ref" x i))) - u8vector-set! + s8vector-set! "(s8vector-ref v i)")) (define u16vector-ref diff --git a/tests/srfi-4-tests.scm b/tests/srfi-4-tests.scm index b6dcebc..5f02ae5 100644 --- a/tests/srfi-4-tests.scm +++ b/tests/srfi-4-tests.scm @@ -17,12 +17,17 @@ (assert (eqv? 100 (,(conc "vector-ref") x 0))) (assert (,(conc "vector?") x)) (assert (number-vector? x)) + ;; Test direct setter and ref (,(conc "vector-set!") x 1 99) (assert (eqv? 99 (,(conc "vector-ref") x 1))) + ;; Test SRFI-17 generalised set! and ref + (set! (,(conc "vector-ref") x 0) 127) + (assert (eqv? 127 (,(conc "vector-ref") x 0))) + ;; Ensure length is okay (assert (= 2 (,(conc "vector-length") x))) (assert (let ((result (,(conc "vector->list") x))) - (and (eqv? 100 (car result)) + (and (eqv? 127 (car result)) (eqv? 99 (cadr result)))))))))) (test1 u8 0 255) -- 2.1.4