From 04bc619b7d6f73497acf885f8bc832f72bc92da2 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Sun, 23 Feb 2020 09:25:08 +0100 Subject: [PATCH] network-tests: Compare hash tables directly. These comparisons wouldn't work before because I was using mutable hashes. --- networks-tests.rkt | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/networks-tests.rkt b/networks-tests.rkt index 8e4645c..9a17c4d 100644 --- a/networks-tests.rkt +++ b/networks-tests.rkt @@ -20,16 +20,14 @@ (test-case "One-step syncronous update" (let* ([s (make-state '((x1 . #t) (x2 . #f)))] [new-s (update bn s '(x2 x1))]) - (check-equal? (hash-ref new-s 'x1) #t) - (check-equal? (hash-ref new-s 'x2) #t) - (check-equal? (length (hash-keys new-s)) 2))) + (check-equal? s #hash((x1 . #t) (x2 . #f))) + (check-equal? new-s #hash((x1 . #t) (x2 . #t))))) (test-case "One-step asynchronous update" (let* ([s (make-state '((x1 . #f) (x2 . #f)))] [new-s (update bn s '(x2 x1))]) - (check-equal? (hash-ref new-s 'x1) #f) - (check-equal? (hash-ref new-s 'x2) #t) - (check-equal? (length (hash-keys new-s)) 2))))) + (check-equal? s #hash((x1 . #f) (x2 . #f))) + (check-equal? new-s #hash((x1 . #f) (x2 . #t))))))) (test-case "Syntactic description of Boolean networks" (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 'a))) - (check-equal? (map hash->list (build-all-states #hash((a . (#t #f)) (b . (1 2 3))))) - '(((a . #t) (b . 1)) - ((a . #t) (b . 2)) - ((a . #t) (b . 3)) - ((a . #f) (b . 1)) - ((a . #f) (b . 2)) - ((a . #f) (b . 3)))) - (check-equal? (hash->list (make-boolean-domains '(a b))) - '((a . (#f #t)) (b . (#f #t)))) + (check-equal? (build-all-states #hash((a . (#t #f)) (b . (1 2 3)))) + '(#hash((a . #t) (b . 1)) + #hash((a . #t) (b . 2)) + #hash((a . #t) (b . 3)) + #hash((a . #f) (b . 1)) + #hash((a . #f) (b . 2)) + #hash((a . #f) (b . 3)))) + (check-equal? (make-boolean-domains '(a b)) + #hash((a . (#f #t)) (b . (#f #t)))) (let* ([n #hash((a . (not b)) (b . a))] [doms (make-boolean-domains '(a b))]