summaryrefslogtreecommitdiff
path: root/test-suite/tests/arrays.test
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27array-contents returns root for empty arrays with empty rootDaniel Llorens1-0/+5
This fixes a compiler issue where (uniform-array->bytevector #2f64()) failed because of the stricter definition of uniform-vector? on this branch. Perhaps it would be better if uniform-array->bytevector didn't require a contiguous argument. * libguile/arrays.c: (scm_array_contents): return the root regardless of the value of SCM_I_ARRAY_DIMS (ra)->inc. * test-suite/tests/arrays.test: check.
2014-01-27Fix compilation bugs with some kinds of typed arraysDaniel Llorens1-1/+9
* module/language/glil/compile-assembly.scm: pass (array-contents x) to uniform-array->bytevector instead of x, when x is a typed array. * test-suite/tests/arrays.test: test an instance of the above that failed in Guile 2.0.9.
2014-01-27Check more cases of array-contentsDaniel Llorens1-1/+11
* libguile/arrays.c: (scm_array_contents): fix comment. * test-suite/tests/arrays.test: add cases that depend on correct setting of CONTIGUOUS_FLAG.
2014-01-27Check the documented matching behavior of array-map!/copy!Daniel Llorens1-40/+0
* test-suite/tests/arrays.test: move array-copy! tests to ramap.test. * test-suite/tests/ramap.test: check the dissimilar matching behavior of array-copy! and array-map! with arguments of different size.
2014-01-27Fix compilation errors when reading arrays at the replDaniel Llorens1-0/+63
* compile-assembly.scm - vector-fold2: handle rank 1 arrays, since this is called with the result of array-contents which need not be a vector. - dump-constants: fix uses of vector-fold2. Replace vector-length on result of array-contents by array-length. * libguile/arrays.c - scm_array_contents: branch cases not on scm_is_generalized_vector but on SCM_I_ARRAYP. Thus lbnd!=0, which could happen with scm_is_generalized_vector, never appears in the output. * test-suite/tests/arrays.test - tests for array-contents.
2014-01-27Test that typed-array? returns #f with non-array argumentDaniel Llorens1-1/+7
* test-suite/tests/arrays.test: ditto.
2014-01-27Identify scm_is_vector with scm_is_simple_vectorDaniel Llorens1-1/+1
This patch fixes the bug (vector-ref #1@1(1 2 3) 1) => 2. * libguile/vectors.c: (scm_is_vector): just as scm_is_simple_vector. * libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c, libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector. * libguile/sort.c - scm_restricted_vector_sort_x: use scm_array_handle_writable_elements instead of scm_vector_writable_elements, to work with non-vector rank-1 array objects. - scm_sort_x: check for scm_is_array instead of scm_is_vector. Rank check is in restricted_vector_sort_x. - scm_sort: ditto. - scm_stable_sort_x: like scm_restricted_vector_sort_x. - scm_stable_sort: like scm_sort. * test-suite/tests/arrays.test: fix header. * test-suite/tests/random.test: new coverage test covering random:normal-vector! * test-suite/Makefile.am: include random.test in make check.
2014-01-27For uniform vectors SCM_I_ARRAYP can't be trueDaniel Llorens1-22/+36
This fixes an inconsistency where uniform-vector? of a shared array could be true but -ref operations failed to account correctly for lbnd. * libguile/uniform.c - scm_is_uniform_vector: SCM_I_ARRAYP disqualifies obj as uniform vector. - scm_c_uniform_vector_length: lbnd is known 0, so don't use it. - scm_c_uniform_vector_ref: lbnd/base/inc are known to be 0/0/1. - scm_c_uniform_vector_set_x!: idem. - scm_uniform_vector_writable_elements: check uvec's type. * test-suite/tests/arrays.test - group the exception types at the top. - check that uniform-vector functions do not accept general arrays.
2014-01-27Reorder arrays.testDaniel Llorens1-152/+152
* test-suite/tests/arrays.test: dependence reordering: first sanity, then make-array, then array-equal?, then make-shared-array, shared-array-root, then the rest, many of which use make-shared-array.
2014-01-27Don't use scm_is_generalized_vector in transpose-arrayDaniel Llorens1-0/+13
* libguile/arrays.c (scm_transpose_array) - Use scm_c_array_rank(), which contains an implicit is_array test. - Handle the rank 0 case. * test-suite/tests/arrays.test - Add test for rank 0 case. - Add failure test for non array argument.
2014-01-27Tests for transpose-arrayDaniel Llorens1-0/+32
* test-suite/tests/arrays.test: test transpose-array for ranks 1, 2, 3.
2014-01-27Tests for shared-array-rootDaniel Llorens1-0/+29
* test-suite/tests/arrays.test: check shared-array-root against make-shared-array, array-contents.
2014-01-27Don't use generalized-vector functions in uniform.cDaniel Llorens1-4/+20
* libguile/uniform.c - (scm_is_uniform_vector): replace scm_is_generalized_vector and scm_generalized_vector_get_handle by scm_is_array and manual rank check. - (scm_c_uniform_vector_length): inline length computation. This removes a redundant rank check. - (scm_c_uniform_vector_ref): inline impl->vref use. This removes a redundant rank check. - (scm_c_uniform_vector_set): inline impl->vset use. This removes a redundant rank check. - (scm_uniform_vector_writable_elements): replace scm_generalized_vector_get_handle by scm_array_get_handle. * test-suite/test/arrays.test - rename uniform-vector-ref block to uniform-vector. - exercise uniform-vector-length and shared arrays remaining uniform.
2013-04-05Remove double indirection in array-fill!Daniel Llorens1-1/+9
* libguile/array-map.c: new function rafill, like scm_array_fill_int, but factors GVSET out of the loop. Use it in scm_array_fill_x instead of scm_array_fill_int. * test-suite/tests/arrays.test: add test for array-fill! with stride != 1. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05Tests for array-copy!Daniel Llorens1-0/+40
* test-suite/tests/arrays.test: tests for arguments of rank 0, 1 and 2. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-02-18deprecate generalized vectors in favor of arraysAndy Wingo1-22/+0
* libguile/generalized-arrays.h: * libguile/generalized-arrays.c (scm_c_array_length): (scm_array_length): New functions. * module/ice-9/deprecated.scm: * libguile/generalized-vectors.c: * libguile/generalized-vectors.h: * libguile/deprecated.h: * libguile/deprecated.c (scm_generalized_vector_p) (scm_generalized_vector_length, scm_generalized_vector_ref) (scm_generalized_vector_set_x, scm_generalized_vector_to_list): Deprecate. * libguile/uniform.c (scm_uniform_vector_to_list): Use scm_array_to_list. * module/ice-9/boot-9.scm (case): Arrays are generalized vectors. * module/srfi/srfi-4/gnu.scm (define-any->vector): Use the array functions instead of the generalized-vector functions. * test-suite/tests/arrays.test: Remove generalized-vector->list test; covered by array->list test. * test-suite/tests/bitvectors.test: * test-suite/tests/bytevectors.test: * test-suite/tests/srfi-4.test: Adapt to test using array interfaces instead of generalized-vector interfaces. * doc/ref/api-compound.texi: Remove generalized vector docs. * doc/ref/api-data.texi: * doc/ref/srfi-modules.texi: Adapt.
2013-02-18optimize access to arrays of rank 1 or 2Andy Wingo1-2/+2
* libguile/array-handle.c (scm_array_handle_pos_1): (scm_array_handle_pos_2): New functions. * libguile/generalized-arrays.c (scm_c_array_ref_1, scm_c_array_ref_2): (scm_c_array_set_1_x, scm_c_array_set_2_x): New functions. (scm_i_array_ref, scm_i_array_set_x): New subr bindings for array-ref and array-set! that avoid consing for arrays of rank 1 or 2. * test-suite/tests/arrays.test ("array-set!"): Fix expected exception for wrong number of indices.
2012-11-03Fix `generalized-vector->list' indexing bug with shared arrays.Ludovic Courtès1-1/+31
Fixes <http://bugs.gnu.org/12465>. Reported by Daniel Llorens <daniel.llorens@bluewin.ch>. * libguile/generalized-vectors.c (scm_generalized_vector_to_list): Fix initial value of POS; pass the `h.base + pos', not just `pos' as the `vref' argument. * test-suite/tests/arrays.test ("array->list")["http://bugs.gnu.org/12465 - ok", "http://bugs.gnu.org/12465 - bad]: New tests. ("generalized-vector->list"): New test prefix.
2012-11-02test-suite: Add a nameless form of `pass-if-equal'.Ludovic Courtès1-5/+5
* test-suite/test-suite/lib.scm (pass-if-equal): Add a nameless pattern. * test-suite/tests/arrays.test ("array->list"): Use `pass-if-equal'.
2011-12-22fix generalized-vector-{ref,set!} for slicesAndy Wingo1-1/+17
* libguile/generalized-vectors.c (scm_c_generalized_vector_ref): (scm_c_generalized_vector_set_x): Fix for the case in which base was not 1, lbnd was not 0, or inc was not 1. * test-suite/tests/arrays.test (array): Add a test. Thanks to Daniel Llorens for the report.
2010-04-07add docs and tests for array->listAndy Wingo1-0/+11
* libguile/generalized-arrays.c (scm_array_to_list): Add docs. * test-suite/tests/arrays.test ("array->list"): Add tests.
2010-04-01more fixes to equal? for arraysAndy Wingo1-0/+21
* libguile/array-map.c (array_compare, scm_array_equal_p): Rewrite as something that operates on the generic array handle infrastructure. Based on array->list. (scm_i_array_equal_p): Change the docs, as array-equal? is now the same as equal?, except that it typechecks its args. * doc/ref/api-compound.texi (Array Procedures): Update array-equal? docs. * libguile/deprecated.h: * libguile/deprecated.c (scm_raequal): Deprecate. * libguile/bytevectors.c (scm_bytevector_eq_p): Bugfix: bytevectors are bytevector=? only if their element type is the same. * libguile/eq.c (scm_equal_p): Only dispatch to scm_array_equal_p if both args are arrays (generically). * test-suite/tests/arrays.test ("equal?"): Add some more tests.
2010-03-31rename unif.test to arrays.testAndy Wingo1-6/+559
* test-suite/tests/arrays.test: Move all unif.test here. Unif.test was mostly testing arrays anyway. Incorporate the existing arrays.test. * test-suite/tests/unif.test: Deleted. * test-suite/Makefile.am: Update.
2010-03-31fix equal? between an array and a non-arrayAndy Wingo1-0/+23
OK let's try again. While the thanks go to Daniel Llorens del Río for the tip, the blame continues going to me :) * test-suite/Makefile.am: * test-suite/tests/arrays.test: Add a test. * libguile/array-map.c (raeql): Handle a few 0-dimensional cases. If the shapes of the arrays don't match, just return #f instead of raising an error.
2010-03-30Revert "fix equal? between an array and a non-array"Andy Wingo1-23/+0
This reverts commit 9d031d4d575ac8f343a5d984cb02cd374577c5a9.
2010-03-30fix equal? between an array and a non-arrayAndy Wingo1-0/+23
* libguile/eq.c (scm_equal_p): Only call scm_array_equal_p if both arguments are generalized arrays; otherwise they are not equal. Thanks to Daniel Llorens del Río for the tip. * test-suite/Makefile.am: * test-suite/tests/arrays.test: Add a test.