26 lines
856 B
Racket
26 lines
856 B
Racket
#lang typed/racket
|
|
|
|
;;; Tests for dds/utils.
|
|
|
|
(require typed/rackunit "utils.rkt")
|
|
|
|
(test-begin
|
|
(test-case "auto-hash-ref/explicit"
|
|
(let ([mytable #hash((a . 3) (b . 4))])
|
|
(check-equal? (auto-hash-ref/explicit (mytable b a)
|
|
(* a b))
|
|
12))
|
|
(let ([ht #hash((a . #t) (b . #f))])
|
|
(check-equal? (auto-hash-ref/explicit (ht a b)
|
|
(and (not a) b))
|
|
#f)))
|
|
|
|
(test-case "auto-hash-ref/:"
|
|
(let ([ht #hash((x . #t) (y . #t) (t . #f))]
|
|
[z #t])
|
|
(check-equal? (auto-hash-ref/: ht
|
|
(and :x (not :y) z (or (and :t) :x)))
|
|
#f))
|
|
(let ([ht #hash((a . 1) (b . 2))])
|
|
(check-equal? (auto-hash-ref/: ht (+ :a (* 2 :b)))
|
|
5))))
|