network-tests: Compare hash tables directly.

These comparisons wouldn't work before because I was using mutable
hashes.
This commit is contained in:
Sergiu Ivanov 2020-02-23 09:25:08 +01:00
parent 4a6888ddde
commit 04bc619b7d

View file

@ -20,16 +20,14 @@
(test-case "One-step syncronous update" (test-case "One-step syncronous update"
(let* ([s (make-state '((x1 . #t) (x2 . #f)))] (let* ([s (make-state '((x1 . #t) (x2 . #f)))]
[new-s (update bn s '(x2 x1))]) [new-s (update bn s '(x2 x1))])
(check-equal? (hash-ref new-s 'x1) #t) (check-equal? s #hash((x1 . #t) (x2 . #f)))
(check-equal? (hash-ref new-s 'x2) #t) (check-equal? new-s #hash((x1 . #t) (x2 . #t)))))
(check-equal? (length (hash-keys new-s)) 2)))
(test-case "One-step asynchronous update" (test-case "One-step asynchronous update"
(let* ([s (make-state '((x1 . #f) (x2 . #f)))] (let* ([s (make-state '((x1 . #f) (x2 . #f)))]
[new-s (update bn s '(x2 x1))]) [new-s (update bn s '(x2 x1))])
(check-equal? (hash-ref new-s 'x1) #f) (check-equal? s #hash((x1 . #f) (x2 . #f)))
(check-equal? (hash-ref new-s 'x2) #t) (check-equal? new-s #hash((x1 . #f) (x2 . #t)))))))
(check-equal? (length (hash-keys new-s)) 2)))))
(test-case "Syntactic description of Boolean networks" (test-case "Syntactic description of Boolean networks"
(let ([s (make-state '((x . #t) (y . #f)))] (let ([s (make-state '((x . #t) (y . #f)))]
@ -60,15 +58,15 @@
(check-false (has-edge? ig 'c 'b)) (check-false (has-edge? ig 'c 'b))
(check-false (has-edge? ig 'c 'a))) (check-false (has-edge? ig 'c 'a)))
(check-equal? (map hash->list (build-all-states #hash((a . (#t #f)) (b . (1 2 3))))) (check-equal? (build-all-states #hash((a . (#t #f)) (b . (1 2 3))))
'(((a . #t) (b . 1)) '(#hash((a . #t) (b . 1))
((a . #t) (b . 2)) #hash((a . #t) (b . 2))
((a . #t) (b . 3)) #hash((a . #t) (b . 3))
((a . #f) (b . 1)) #hash((a . #f) (b . 1))
((a . #f) (b . 2)) #hash((a . #f) (b . 2))
((a . #f) (b . 3)))) #hash((a . #f) (b . 3))))
(check-equal? (hash->list (make-boolean-domains '(a b))) (check-equal? (make-boolean-domains '(a b))
'((a . (#f #t)) (b . (#f #t)))) #hash((a . (#f #t)) (b . (#f #t))))
(let* ([n #hash((a . (not b)) (b . a))] (let* ([n #hash((a . (not b)) (b . a))]
[doms (make-boolean-domains '(a b))] [doms (make-boolean-domains '(a b))]