guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 01/01: Non-vector 1D arrays print as #1()


From: Daniel Llorens
Subject: [Guile-commits] 01/01: Non-vector 1D arrays print as #1()
Date: Wed, 18 Feb 2015 21:53:40 +0000

lloda pushed a commit to branch master
in repository guile.

commit eb3d623da57e6d31a58d95f932345fb761f9b701
Author: Daniel Llorens <address@hidden>
Date:   Wed Feb 18 09:32:30 2015 +0100

    Non-vector 1D arrays print as #1()
    
    * libguile/arrays.c (scm_i_print_array): Print the dimension whenever
      the array is a true scm_tc7_array.
    
    * test-suite/tests/arrays.test: Check that non-vector 1D arrays print as
      expected.
---
 libguile/arrays.c            |    5 +++--
 test-suite/tests/arrays.test |   14 +++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/libguile/arrays.c b/libguile/arrays.c
index 9e5715c..4c1b824 100644
--- a/libguile/arrays.c
+++ b/libguile/arrays.c
@@ -1,5 +1,6 @@
 /* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004,2005,
- *   2006, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ *   2006, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation,
+ *   Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -760,7 +761,7 @@ scm_i_print_array (SCM array, SCM port, scm_print_state 
*pstate)
   scm_array_get_handle (array, &h);
 
   scm_putc_unlocked ('#', port);
-  if (h.ndims != 1 || h.dims[0].lbnd != 0)
+  if (SCM_I_ARRAYP (array))
     scm_intprint (h.ndims, 10, port);
   if (h.element_type != SCM_ARRAY_ELEMENT_TYPE_SCM)
     scm_write (scm_array_handle_element_type (&h), port);
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
index 66316fe..e76c699 100644
--- a/test-suite/tests/arrays.test
+++ b/test-suite/tests/arrays.test
@@ -1,6 +1,7 @@
 ;;;; arrays.test --- tests guile's uniform arrays     -*- scheme -*-
 ;;;;
-;;;; Copyright 2004, 2006, 2009, 2010, 2011, 2012, 2013, 2014 Free Software 
Foundation, Inc.
+;;;; Copyright 2004, 2006, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free
+;;;; Software Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -817,3 +818,14 @@
                    #u32(2 3)))
   (pass-if (equal? (array-ref (array-row #2u32((0 1) (2 3)) 1) 0)
                    2)))
+
+;;;
+;;; printing arrays
+;;;
+
+(with-test-prefix/c&e "printing arrays"
+  (pass-if-equal "writing 1D arrays that aren't vectors"
+    "#1(b c)"
+    (format #f "~a" (make-shared-array #(a b c)
+                                       (lambda (i) (list (+ i 1)))
+                                       2))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]