Test output for random-access-lists [ok]

Testing time: 1s

'/usr/home/chicken/salmonella/build/salmonella-run-publish/chicken/bin/csi' -script run.scm < /dev/null 2>&1

Testing random-access-lists ...
----------------------------
"AN EMPTY RAL OF INTEGERS"
... passed in (ra-list)
(define ls (make-ral fixnum?))
... passed in (ra-list)
(ral? ls)
... passed in (ra-list)
(ral-null? ls)
... passed in (ra-list)
(fx= (ral-height ls) 1)
... passed in (ra-list)
"POPULATE IT AT THE RIGHT END"
... passed in (ra-list)
(ral-add! ls 0 1 2 3 4)
... passed in (ra-list)
(fx= (ral-count ls) 5)
... passed in (ra-list)
(equal? (ral->list ls) '(0 1 2 3 4))
... passed in (ra-list)
"REMOVE SOME ITEMS"
... passed in (ra-list)
(ral-remove! ls 2)
... passed in (ra-list)
(fx= (ral-count ls) 4)
... passed in (ra-list)
(equal? (ral->list ls) '(0 1 3 4))
... passed in (ra-list)
(ral-remove! ls (fx- (ral-count ls) 1))
... passed in (ra-list)
(fx= (ral-count ls) 3)
... passed in (ra-list)
(equal? (ral->list ls) '(0 1 3))
... passed in (ra-list)
(ral-remove! ls 0)
... passed in (ra-list)
(fx= (ral-count ls) 2)
... passed in (ra-list)
(equal? (ral->list ls) '(1 3))
... passed in (ra-list)
"INSERT AN ITEM"
... passed in (ra-list)
(ral-insert! ls 1 2)
... passed in (ra-list)
(fx= (ral-ref ls 1) 2)
... passed in (ra-list)
(fx= (ral-count ls) 3)
... passed in (ra-list)
(equal? (ral->list ls) '(1 2 3))
... passed in (ra-list)
"RESET RAL"
... passed in (ra-list)
(ral-clear! ls)
... passed in (ra-list)
(ral-null? ls)
... passed in (ra-list)
"POPULATE RAL AGAIN"
... passed in (ra-list)
(do ((k 0 (fx+ 1 k))) ((fx= k 100)) (ral-add! ls k))
... passed in (ra-list)
(fx= (ral-count ls) 100)
... passed in (ra-list)
"SPLIT, JOIN AND SUBRAL"
... passed in (ra-list)
(ral-eql? fx= ls (receive (head tail) (ral-split ls 50) (ral-join head tail)))
... passed in (ra-list)
(equal?
  (ral->list (ral-from-upto ls 20 70))
  (let loop ((k 69) (result '()))
    (if (fx= k 19) result (loop (fx- k 1) (cons k result)))))
... passed in (ra-list)
"INSPECT AND CHANGE AN ITEM IN THE MIDDLE"
... passed in (ra-list)
(fx= (ral-ref ls 50) 50)
... passed in (ra-list)
(ral-set! ls 50 500)
... passed in (ra-list)
(fx= (ral-ref ls 50) 500)
... passed in (ra-list)
"CHANGE ITEM BACK AGAIN"
... passed in (ra-list)
(ral-set! ls 50 50)
... passed in (ra-list)
(fx= (ral-ref ls 50) 50)
... passed in (ra-list)
"CHANGE ITEMS AT THE ENDS AND BACK AGAIN"
... passed in (ra-list)
(ral-set! ls 0 1000)
... passed in (ra-list)
(fx= (ral-ref ls 0) 1000)
... passed in (ra-list)
(ral-set! ls 0 0)
... passed in (ra-list)
(fx= (ral-ref ls 0) 0)
... passed in (ra-list)
(ral-set! ls 99 1000)
... passed in (ra-list)
(fx= (ral-ref ls 99) 1000)
... passed in (ra-list)
(ral-set! ls 99 99)
... passed in (ra-list)
(fx= (ral-ref ls 99) 99)
... passed in (ra-list)
"INSERT AT LEFT END"
... passed in (ra-list)
(ral-add-left! ls -1 -2 -3)
... passed in (ra-list)
(fx= (ral-ref ls 0) -3)
... passed in (ra-list)
(fx= (ral-ref ls 1) -2)
... passed in (ra-list)
(fx= (ral-ref ls 2) -1)
... passed in (ra-list)
"REMOVE THEM AGAIN"
... passed in (ra-list)
(ral-remove! ls 0)
... passed in (ra-list)
(ral-remove! ls 0)
... passed in (ra-list)
(ral-remove! ls 0)
... passed in (ra-list)
(fx= (ral-ref ls 0) 0)
... passed in (ra-list)
(fx= (ral-count ls) 100)
... passed in (ra-list)
"INSERT AT RIGHT END AND REMOVE IT AGAIN"
... passed in (ra-list)
(ral-add! ls 100 101)
... passed in (ra-list)
(fx= (ral-ref ls (fx- (ral-count ls) 1)) 101)
... passed in (ra-list)
(ral-remove! ls (fx- (ral-count ls) 1))
... passed in (ra-list)
(ral-remove! ls (fx- (ral-count ls) 1))
... passed in (ra-list)
(fx= (ral-ref ls (fx- (ral-count ls) 1)) 99)
... passed in (ra-list)
"INSERT IN THE MIDDLE AND REMOVE IT AGAIN"
... passed in (ra-list)
(ral-insert! ls 20 200)
... passed in (ra-list)
(fx= (ral-ref ls 20) 200)
... passed in (ra-list)
(fx= (ral-ref ls 21) 20)
... passed in (ra-list)
(fx= (ral-count ls) 101)
... passed in (ra-list)
(ral-remove! ls 20)
... passed in (ra-list)
(fx= (ral-ref ls 20) 20)
... passed in (ra-list)
(fx= (ral-count ls) 100)
... passed in (ra-list)
"RESTRUCTURE"
... passed in (ra-list)
(define lsr (ral-restructure ls 4 20))
... passed in (ra-list)
(ral-eql? fx= ls lsr)
... passed in (ra-list)
(fx= (ral-width lsr) 4)
... passed in (ra-list)
(fx= (ral-max-height lsr) 20)
... passed in (ra-list)
"MAP AND FILTER"
... passed in (ra-list)
(equal?
  (ral->list (ral-map ls add1))
  (let loop ((k 100) (result '()))
    (if (fx= k 0) result (loop (fx- k 1) (cons k result)))))
... passed in (ra-list)
(equal?
  (ral->list (ral-filter ls odd?))
  (let loop ((k 99) (result '()))
    (if (fx< k 0) result (loop (fx- k 2) (cons k result)))))
... passed in (ra-list)

Results of random-access-lists
----------------------------
All tests passed