ashinn / chibi-scheme

Official chibi-scheme repository
Other
1.23k stars 141 forks source link

SRFI 231: remaining list*->array and vector*->array errors #962

Closed gambiteer closed 6 months ago

gambiteer commented 6 months ago

I found these this morning, I don't know whether it's a problem with interval cursors, array-every, interval-fold, ... (or the tests)

    FAIL: (array-every equal? (list*->array 1 '((a b c) (1 2 3))) (list->...
        assertion failed
        on line 739 of file "test-arrays.scm"
        (array-every equal? (list*->array 1 '((a b c) (1 2 3))) (list->array (make-interval '#(2)) '((a b c) (1 2 3))))
    FAIL: (array-every equal? (list*->array 2 '(((a b c) (1 2 3)))) (list...
        assertion failed
        on line 751 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '(((a b c) (1 2 3)))) (list->array (make-interval '#(1 2)) '((a b c) (1 2 3))))
    FAIL: (array-every equal? (list*->array 2 '(((a b c) (1 2)))) (list->...
        assertion failed
        on line 757 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '(((a b c) (1 2)))) (list->array (make-interval '#(1 2)) '((a b c) (1 2))))
    ERROR: (array-every equal? (list*->array 0 '()) (make-array (make-inte...
        Exception: car: not a pair: ()
        on line 761 of file "test-arrays.scm"
        (array-every equal? (list*->array 0 '()) (make-array (make-interval '#()) (lambda () '())))
    ERROR: (array-every equal? (list*->array 1 '()) (make-array (make-inte...
        Exception: car: not a pair: ()
        on line 764 of file "test-arrays.scm"
        (array-every equal? (list*->array 1 '()) (make-array (make-interval '#(0)) (lambda () (error))))
    ERROR: (array-every equal? (list*->array 2 '()) (make-array (make-inte...
        Exception: car: not a pair: ()
        on line 767 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '()) (make-array (make-interval '#(0 0)) (lambda () (error))))
    ERROR: (array-every equal? (list*->array 2 '(() ())) (make-array (make...
        Exception: car: not a pair: ()
        on line 770 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '(() ())) (make-array (make-interval '#(2 0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 0 '#()) (make-array (make-i...
        Exception: vector-ref: index out of range
    #()
    0
        on line 791 of file "test-arrays.scm"
        (array-every equal? (vector*->array 0 '#()) (make-array (make-interval '#()) (lambda () '#())))
    ERROR: (array-every equal? (vector*->array 1 '#()) (make-array (make-i...
        Exception: vector-ref: index out of range
    #()
    0
        on line 794 of file "test-arrays.scm"
        (array-every equal? (vector*->array 1 '#()) (make-array (make-interval '#(0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 2 '#()) (make-array (make-i...
        Exception: vector-ref: index out of range
    #()
    0
        on line 797 of file "test-arrays.scm"
        (array-every equal? (vector*->array 2 '#()) (make-array (make-interval '#(0 0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 2 '#(#() #())) (make-array ...
        Exception: vector-ref: index out of range
    #()
    0
        on line 800 of file "test-arrays.scm"
        (array-every equal? (vector*->array 2 '#(#() #())) (make-array (make-interval '#(2 0)) (lambda () (error))))
ashinn commented 6 months ago

I fixed some of these. For the tests with zero-dimensional arrays, they have a single index (the empty list), corresponding to a single element, so your examples giving them no elements throw an exception. i.e.

(list*->array 0 '())  => exception
(list*->array 0 '(3))  => ok

This seems to be the correct interpretation to me? Interestingly, zero-dimensional arrays are the only dimension that can't be empty.

gambiteer commented 6 months ago

Re:

(list*->array 0 '())  => exception
(list*->array 0 '(3))  => ok

The first one returns a zero-dimensional array whose sole element is the empty list, the second a zero-dimensional array whose sole element is the list '(3).

ashinn commented 6 months ago

Ah, right, thanks. I'm thinking too much in terms of tensors, and the examples putting lists in arrays keep throwing me off...

gambiteer commented 6 months ago

I still see these errors:

    ERROR: (array-every equal? (list*->array 1 '()) (make-array (make-inte...
        Exception: car: not a pair: ()
        on line 766 of file "test-arrays.scm"
        (array-every equal? (list*->array 1 '()) (make-array (make-interval '#(0)) (lambda () (error))))
    ERROR: (array-every equal? (list*->array 2 '()) (make-array (make-inte...
        Exception: car: not a pair: ()
        on line 769 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '()) (make-array (make-interval '#(0 0)) (lambda () (error))))
    ERROR: (array-every equal? (list*->array 2 '(() ())) (make-array (make...
        Exception: car: not a pair: ()
        on line 772 of file "test-arrays.scm"
        (array-every equal? (list*->array 2 '(() ())) (make-array (make-interval '#(2 0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 1 '#()) (make-array (make-i...
        Exception: vector-ref: index out of range
    #()
    0
        on line 796 of file "test-arrays.scm"
        (array-every equal? (vector*->array 1 '#()) (make-array (make-interval '#(0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 2 '#()) (make-array (make-i...
        Exception: vector-ref: index out of range
    #()
    0
        on line 799 of file "test-arrays.scm"
        (array-every equal? (vector*->array 2 '#()) (make-array (make-interval '#(0 0)) (lambda () (error))))
    ERROR: (array-every equal? (vector*->array 2 '#(#() #())) (make-array ...
        Exception: vector-ref: index out of range
    #()
    0
        on line 802 of file "test-arrays.scm"
        (array-every equal? (vector*->array 2 '#(#() #())) (make-array (make-interval '#(2 0)) (lambda () (error))))