404362a91c
I am very early in my project, and I have already spent literal days trying to make the types fit together. I'm trying contracts next.
35 lines
1.1 KiB
Racket
35 lines
1.1 KiB
Racket
#lang racket
|
|
|
|
;;; Tests for dds/utils.
|
|
|
|
(require rackunit "utils.rkt")
|
|
|
|
(test-case "HashTable Injection"
|
|
(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)))
|
|
|
|
(test-case "eval-with"
|
|
(check-equal? (let ([ht #hash((a . 1) (b . 1))])
|
|
(eval-with1 ht '(+ b a 1)))
|
|
3)))
|
|
|
|
(test-case "Analysis of quoted expressions"
|
|
(check-equal? (extract-symbols '(1 (2 3) x (y z 3)))
|
|
'(x y z)))
|