On Thu, Apr 13, 2017 at 02:25:41PM +0200, Peter Bex wrote:
> On Thu, Apr 13, 2017 at 02:19:00PM +0200, Kristian Lein-Mathisen wrote:
> > Hi Chickeners,
> > 
> > As the commit says, this fixes a typo in s8vector-ref's setter.
> 
> Hi Kristian,
> 
> Well spotted, and a good fix, but could you also update the tests to
> include a regression tests for this and add a NEWS entry for 4.12.1?

I went ahead and added this to your patch (blame my impatience :P).
Attached are patches for master and chicken-5.

Cheers,
Peter
From 1fc800d85f2ecd18bbdaadc98c50c4336ce6af92 Mon Sep 17 00:00:00 2001
From: Kristian Lein-Mathisen <[email protected]>
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 <[email protected]>
---
 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 b43e851..4713c83 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,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 69f58ba..89e62ae 100644
--- a/srfi-4.scm
+++ b/srfi-4.scm
@@ -189,7 +189,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 9daaa78..9af6c25 100644
--- a/tests/srfi-4-tests.scm
+++ b/tests/srfi-4-tests.scm
@@ -16,12 +16,17 @@
 	  (assert (= 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 (= 99 (,(conc "vector-ref") x 1)))
+	  ;; Test SRFI-17 generalised set! and ref
+	  (set! (,(conc "vector-ref") x 0) 127)
+	  (assert (= 127 (,(conc "vector-ref") x 0)))
+	  ;; Ensure length is okay
 	  (assert (= 2 (,(conc "vector-length") x)))
 	  (assert
 	   (every =
-		  '(100 99)
+		  '(127 99)
 		  (,(conc "vector->list") x))))))))
 
 (test1 u8)
-- 
2.1.4

From 16051070722bc433fad92a83c7522837257cf071 Mon Sep 17 00:00:00 2001
From: Kristian Lein-Mathisen <[email protected]>
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 <[email protected]>

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

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to