(declare (extended-bindings) (not constant-fold) (not safe))

(define v1 (##u32vector 0 111 4294967295))
(define v2 (##make-u32vector 10))
(define v3 (##make-u32vector 10 111))
(define v4 (##make-u32vector 10 4294967295))
(define v5 '#u32(0 111 4294967295))

(define (int= x y)
  (if (##fixnum? x)
      (and (##fixnum? y)
           (##fx= x y))
      (and (##bignum? x)
           (##bignum? y)
           (let ((len (##bignum.adigit-length x)))
             (and (##fx= len (##bignum.adigit-length y))
                  (let loop ((i (##fx- len 1)))
                    (if (##fx< i 0)
                        (and (##bignum.adigit-= x y i)
                             (loop (##fx- i 1)))
                        #t)))))))
        
(define (test v i expected)
  (let ((val (##u32vector-ref v i))) 
    (println (if (int= val expected) "good" "bad"))))

(test v1 0 0)
(test v1 1 111)
(test v1 2 4294967295)

(test v2 9 0)
(test v3 9 111)
(test v4 9 4294967295)

(test v5 0 0)
(test v5 1 111)
(test v5 2 4294967295)
