;;;; sparse-vectors-debug-test.scm (import test) ;;; (test-begin "Sparse Vectors Debug") (import sparse-vectors (sparse-vectors debug)) (import (chicken base) (chicken fixnum) (chicken bitwise) (chicken sort)) (import (srfi 1) record-variants) (include-relative "../sparse-vectors-inlines") ;; ;for alist comparison (define (sval< a b) (< (car a) (car b))) (define (sval> a b) (> (car a) (car b))) (define (asc-sv sv) (sort sv sval<)) (define (dsc-sv sv) (sort sv sval>)) ;almost (define (vector->hilbert-node hilbert vec) (let-values (((ct ht sz) (sparse-vector-info hilbert))) (append (vector->list vec) (make-list (- sz (vector-length vec)) #f)) ) ) ;; (define Vec1 #(1 2 3)) (define Vec2 #(1 #f 2 #f 3)) (define Lis1 (vector->list Vec1)) (define Lis2 (vector->list Vec2)) ;FIXME .debug test needs to be done early! (test-group "sparse-vector-info" (let ((h1 (make-sparse-vector))) (test '(1 1 256) (receive (sparse-vector-info h1))) ) ) (test-group "sparse-vector-value-kind" (let ((h1 (make-sparse-vector))) (test 'set! (sparse-vector-value-kind 'something)) (test 'node (sparse-vector-value-kind (make-node h1))) (test 'unset! (sparse-vector-value-kind (hilbert-default h1))) ) ) (test-group "sparse-vector-tree-fold" (let ((h1 (make-sparse-vector))) (define (visit a nd ht pt i) (test-assert (node? nd)) (test-assert (fixnum? ht)) (test-assert (or (not pt) (node? pt))) (test-assert (or (not i) (fixnum? i))) (test-assert (if (not pt) (not i) #t)) (test-assert (if pt i #t)) (fx+ a 1) ) (let ((cnt (sparse-vector-tree-fold h1 visit 0))) (test "node count" 1 cnt) ) ) ) ;;; (test-end "Sparse Vectors Debug") (test-exit)