;; tests/ursa-scheme.lsp — Scheme-port only half of the Zoë
;; acceptance suite. Uses zero macros, so it runs under every tier
;; including the minimal asm (no cl-compat needed). Counterpart to
;; tests/ursa.lsp which adds the CL-path tests on top.

(define *pass* 0)
(define *fail* 0)
(define (check name got expected)
  (cond ((equal? got expected)
         (set! *pass* (+ *pass* 1))
         (display "PASS: ") (display name) (newline))
        (else
         (set! *fail* (+ *fail* 1))
         (display "FAIL: ") (display name)
         (display " got=") (write got)
         (display " expected=") (write expected) (newline))))

(load "examples/ursa-scheme.lsp")
(random-seed! 42)

(check "s:expt-mod-3^7%100"   (expt-mod 3 7 100)        87)
(check "s:expt-mod-big"       (expt-mod 2 100 1000)     376)
(check "s:primep-97"          (primep 97)               97)
(check "s:primep-100"         (primep 100)              #f)
(check "s:factor-12"          (factor 12)               '(2 2 3))
(check "s:factor-1001"        (factor 1001)             '(7 11 13))
(check "s:mersenne-5"         (mersenne-number 5)       31)
(check "s:ll-residue-5"       (lucas-lehmer-residue 5)  0)
(check "s:ll-primep-5"        (lucas-lehmer-primep 5)   #t)
(check "s:ll-primep-11"       (lucas-lehmer-primep 11)  #f)
(check "s:ll-primep-13"       (lucas-lehmer-primep 13)  #t)
(check "s:repunit-5"          (repunit-value 5)         31)
(check "s:digits-42-2"        (digits 42 2)             #(1 0 1 0 1 0))
(check "s:digits-roundtrip"   (digits (digits 1234 16) 16) 1234)
(let ((v (of-n-bits 8)))
  (check "s:of-n-bits"        (and (>= v 128) (< v 256)) #t))

(display "══════════════════════════════") (newline)
(display "ursa-scheme: ") (display *pass*) (display " passed, ")
(display *fail*) (display " failed") (newline)
(if (> *fail* 0) (exit 1))
