summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libguile/array-map.c22
-rw-r--r--test-suite/Makefile.am1
-rw-r--r--test-suite/tests/arrays.test23
3 files changed, 39 insertions, 7 deletions
diff --git a/libguile/array-map.c b/libguile/array-map.c
index 2041d0580..46acb2915 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -863,20 +863,29 @@ raeql (SCM ra0, SCM as_equal, SCM ra1)
scm_t_array_dim *s0 = &dim0, *s1 = &dim1;
unsigned long bas0 = 0, bas1 = 0;
int k, unroll = 1, vlen = 1, ndim = 1;
+
if (SCM_I_ARRAYP (ra0))
{
+ if (SCM_I_ARRAY_NDIM (ra0) == 0)
+ return scm_is_true (scm_equal_p (scm_array_ref (ra0, SCM_EOL), ra1));
ndim = SCM_I_ARRAY_NDIM (ra0);
s0 = SCM_I_ARRAY_DIMS (ra0);
bas0 = SCM_I_ARRAY_BASE (ra0);
v0 = SCM_I_ARRAY_V (ra0);
}
- else
+ else if (scm_is_generalized_vector (v0))
{
s0->inc = 1;
s0->lbnd = 0;
s0->ubnd = scm_c_generalized_vector_length (v0) - 1;
unroll = 0;
}
+ else if (SCM_I_ARRAYP (ra1) && SCM_I_ARRAY_NDIM (ra1) == 0)
+ return scm_is_true (scm_equal_p (ra0, scm_array_ref (ra1, SCM_EOL)));
+ else
+ /* It's just not working out, dear. */
+ return 0;
+
if (SCM_I_ARRAYP (ra1))
{
if (ndim != SCM_I_ARRAY_NDIM (ra1))
@@ -885,18 +894,17 @@ raeql (SCM ra0, SCM as_equal, SCM ra1)
bas1 = SCM_I_ARRAY_BASE (ra1);
v1 = SCM_I_ARRAY_V (ra1);
}
- else
+ else if (scm_is_generalized_vector (v1))
{
- /*
- Huh ? Schizophrenic return type. --hwn
- */
- if (1 != ndim)
- return 0;
s1->inc = 1;
s1->lbnd = 0;
s1->ubnd = scm_c_generalized_vector_length (v1) - 1;
unroll = 0;
}
+ else
+ /* It's not you, it's me. */
+ return 0;
+
if (SCM_TYP7 (v0) != SCM_TYP7 (v1))
return 0;
for (k = ndim; k--;)
diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am
index 36afa2560..40f5a9868 100644
--- a/test-suite/Makefile.am
+++ b/test-suite/Makefile.am
@@ -24,6 +24,7 @@ SUBDIRS = standalone
SCM_TESTS = tests/alist.test \
tests/and-let-star.test \
tests/arbiters.test \
+ tests/arrays.test \
tests/asm-to-bytecode.test \
tests/bit-operations.test \
tests/brainfuck.test \
diff --git a/test-suite/tests/arrays.test b/test-suite/tests/arrays.test
new file mode 100644
index 000000000..30dc7502f
--- /dev/null
+++ b/test-suite/tests/arrays.test
@@ -0,0 +1,23 @@
+;;;; arrays.test --- tests guile's arrays -*- scheme -*-
+;;;;
+;;;; Copyright 2010 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 as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;;
+;;;; This library is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;;; Lesser General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free Software
+;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+(define-module (test-suite test-unif)
+ #:use-module (test-suite lib))
+
+(pass-if "equal? on array and non-array"
+ (not (equal? #2f64((0 1) (2 3)) 100)))