summaryrefslogtreecommitdiff
path: root/test-suite/tests/arrays.test
AgeCommit message (Collapse)AuthorFilesLines
2021-08-16Remove the 'simple vector' conceptDaniel Llorens1-1/+1
* Deprecate scm_is_simple_vector. * libguile/vectors.c (scm_vector_elements, scm_vector_writable_elements): These functions take an array; reword to make this clear. * libguile/print.h: Remove reference to 'simple vector'. * doc/ref/api-data.texi: Remove documentation for scm_is_simple_vector. Remove references to 'simple vector'. Fix documentation for scm_vector_elements, scm_vector_writable_elements. * test-suite/tests/arrays.test: * test-suite/tests/vectors.test: Remove references to 'simple vector'.
2021-03-03Fix bug in new array readerDaniel Llorens1-1/+35
* module/ice-9/read.scm (read-array): Return pair for dimension when len is given; single number is lbnd for list->typed-array. * test-suite/tests/arrays.test: More test cases for the reader.
2021-03-02Fix another typo in routine reading arraysDaniel Llorens1-1/+5
* module/ice-9/read.scm: As stated. * test-suite/tests/arrays.test: Test a fixed case.
2017-10-31Fix bitvectors and non-zero lower bound arrays in truncated-printDaniel Llorens1-1/+54
* module/ice-9/arrays.scm (array-print-prefix): New private function. * libguile/arrays.c (scm_i_print_array): Reuse (array-print-prefix) from (ice-9 arrays). Make sure to release the array handle. * module/ice-9/pretty-print.scm (truncated-print): Support bitvectors. Don't try to guess the array prefix but call array-print-prefix from (ice-9 arrays) instead. Fix call to print-sequence to support non-zero lower bound arrays. * test-suite/tests/arrays.test: Test that arrays print properly. * test-suite/tests/print.test: Test truncated-print with bitvectors, non-zero lower bound arrays.
2017-01-09Final names for new array functionsDaniel Llorens1-24/+24
Globally rename (array-from* -> array-slice), (array-from -> array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell -> array-slice-for-each).
2016-11-23Deprecate scm_from_contiguous_arrayDaniel Llorens1-0/+6
scm_from_contiguous_array() was undocumented, unused within Guile, and can be replaced by make-array + array-copy! without requiring contiguity and without loss of performance. * libguile/arrays.c (scm_array_contents): Do not rely on SCM_I_ARRAY_CONTP. * test-suite/tests/arrays.test: Test array-contents with 0-rank array. * libguile/arrays.h: Declare scm_i_shap2ra(), SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG so that scm_from_contiguous_array() can keep using them. * libguile/deprecated.c (scm_from_contiguous_array): Move here from arrays.c. * libguile/deprecated.h (scm_from_contiguous_array): Deprecate. * NEWS: Add deprecation notice.
2016-11-23New functions array-from, array-from*, array-amend!Daniel Llorens1-3/+112
* libguile/arrays.h (scm_array_from, scm_array_from_s, scm_array_amend_x): New declarations. * libguile/arrays.c (scm_array_from, scm_array_from_s, scm_array_amend_x): New functions, export as array-from, array-from*, array-amend!. * test-suite/tests/arrays.test: Tests for array-from, array-from*, array-amend!. Replace with-test-prefix/c&e with with-test-prefix where the array read syntax isn't used.
2016-11-23Avoid unneeded internal use of array handlesDaniel Llorens1-13/+63
* libguile/arrays.c (scm_shared_array_root): Adopt uniform check order. (scm_shared_array_offset, scm_shared_array_increments): Use the array fields directly just as scm_shared_array_root does. (scm_c_array_rank): Moved from libguile/generalized-arrays.c. Don't use array handles, but follow the same type check sequence as the other array functions (shared-array-root, etc). (scm_array_rank): Moved from libguile/generalized-arrays.h. * libguile/arrays.h: Move prototypes here. * test-suite/tests/arrays.test: Tests for shared-array-offset, shared-array-increments.
2016-11-23Fix compilation of rank 0 typed array literalsDaniel Llorens1-1/+7
* module/system/vm/assembler.scm (simple-uniform-vector?): array-length fails for rank 0 arrays; fix the shape condition. * test-suite/tests/arrays.test: Test reading of #0f64(x) in compilation context.
2015-02-18Non-vector 1D arrays print as #1()Daniel Llorens1-1/+13
* 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.
2014-09-30Run some of arrays.test under both compiler & interpreterDaniel Llorens1-33/+36
* test-suite/test-suite/lib.scm (c&e): accept (pass-if exp) clause. * test-suite/tests/arrays.test: use with-prefix/c&e instead of with-prefix where possible.
2014-02-10array-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-02-10Add tests for more kinds of typed arrays.Daniel Llorens1-1/+9
* test-suite/tests/arrays.test: Add more type array tests.
2014-02-10Check more cases of array-contentsDaniel Llorens1-1/+10
* libguile/arrays.c: (scm_array_contents): fix comment. * test-suite/tests/arrays.test: add cases that depend on correct setting of CONTIGUOUS_FLAG.
2014-02-10Refactor array-contentsDaniel Llorens1-0/+65
* 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: Test array-contents.
2014-02-10Check 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-02-09Test that typed-array? returns #f with non-array argumentDaniel Llorens1-1/+7
* test-suite/tests/arrays.test: ditto.
2014-02-08Change uses of scm_is_simple_vector to scm_is_vectorDaniel Llorens1-1/+1
* 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_sort_x, scm_sort, scm_stable_sort_x) (scm_stable_sort): Remove scm_is_vector check; scm_is_array is sufficient. * 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-02-08Merge commit 'fb7dd00169304a5922838e4d2f25253640a35def'Andy Wingo1-18/+11
This commit also renames uniform-vector-element-type-code to array-type-code. Conflicts: libguile/uniform.c libguile/uniform.h test-suite/tests/arrays.test
2014-02-08Deprecate general "uniform-vector" interfaceAndy Wingo1-13/+6
* libguile/uniform.h: * libguile/uniform.c (scm_is_uniform_vector, scm_uniform_vector_p) (scm_c_uniform_vector_length, scm_uniform_vector_length) (scm_uniform_vector_element_type, scm_uniform_vector_element_size) (scm_c_uniform_vector_ref, scm_uniform_vector_ref): (scm_c_uniform_vector_set_x, scm_uniform_vector_set_x): (scm_uniform_vector_to_list) (scm_uniform_vector_elements, scm_uniform_vector_writable_elements): Deprecate. This interface lacked both generality and specificity. The general replacement is array-length, array-ref, and friends on the scheme side, or the array handle interface on the C side. On the specific side of things, there are the specific bytevector, srfi-4, and bitvector interfaces. * test-suite/tests/arrays.test: * test-suite/tests/bitvectors.test: * test-suite/tests/ports.test: * test-suite/tests/srfi-4.test: Update to use array interfaces. * doc/ref/api-foreign.texi (Void Pointers and Byte Access): * doc/ref/srfi-modules.texi (SRFI-4): Update.
2014-02-06Reorder 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-02-06Don'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-02-06Tests for transpose-arrayDaniel Llorens1-0/+32
* test-suite/tests/arrays.test: test transpose-array for ranks 1, 2, 3.
2014-02-06Tests for shared-array-rootDaniel Llorens1-0/+29
* test-suite/tests/arrays.test: check shared-array-root against make-shared-array, array-contents.
2014-02-06Don'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): Use scm_c_array_length. (scm_c_uniform_vector_ref): Use scm_c_array_ref_1. (scm_c_uniform_vector_set): Use scm_c_array_set_1_x. (scm_uniform_vector_writable_elements): Use scm_array_get_handle, and assert that the rank is 1. * test-suite/test/arrays.test: Rename the uniform-vector-ref block to uniform-vector. Exercise uniform-vector-length and shared arrays remaining uniform. Modifications by Andy Wingo <wingo@pobox.com>.
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.