From 6b9dd5a0112ed696f5b8b02b605b6daa27263bba Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sun, 4 Mar 2018 11:13:52 -0800 Subject: [PATCH] test JSON using jsexpr --- .../jsonic-demo-2/test-sources.rkt | 20 +++++++++---------- .../jsonic-demo-3/test-sources.rkt | 20 +++++++++---------- .../jsonic-demo/test-sources.rkt | 20 +++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/beautiful-racket-demo/jsonic-demo-2/test-sources.rkt b/beautiful-racket-demo/jsonic-demo-2/test-sources.rkt index 8f8ad0b..26edbaa 100644 --- a/beautiful-racket-demo/jsonic-demo-2/test-sources.rkt +++ b/beautiful-racket-demo/jsonic-demo-2/test-sources.rkt @@ -1,11 +1,11 @@ #lang at-exp br -(require br/test rackunit) - -(check-equal? (run-source "jsonic-test.rkt") @string-append{ -[ - null, - 42, - true, - ["array","of","strings"], - {"key-2":false,"key-1":null,"key-3":{"subkey":21}} -]}) \ No newline at end of file +(require br/test rackunit json) + +;; don't compare string output directly because +;; hash element isn't converted in a reliable order +(check-equal? (string->jsexpr (run-source "jsonic-test.rkt")) + '(null + 42 + #t + ("array" "of" "strings") + #hasheq((key-1 . null) (key-2 . #f) (key-3 . #hasheq((subkey . 21)))))) \ No newline at end of file diff --git a/beautiful-racket-demo/jsonic-demo-3/test-sources.rkt b/beautiful-racket-demo/jsonic-demo-3/test-sources.rkt index 8f8ad0b..26edbaa 100644 --- a/beautiful-racket-demo/jsonic-demo-3/test-sources.rkt +++ b/beautiful-racket-demo/jsonic-demo-3/test-sources.rkt @@ -1,11 +1,11 @@ #lang at-exp br -(require br/test rackunit) - -(check-equal? (run-source "jsonic-test.rkt") @string-append{ -[ - null, - 42, - true, - ["array","of","strings"], - {"key-2":false,"key-1":null,"key-3":{"subkey":21}} -]}) \ No newline at end of file +(require br/test rackunit json) + +;; don't compare string output directly because +;; hash element isn't converted in a reliable order +(check-equal? (string->jsexpr (run-source "jsonic-test.rkt")) + '(null + 42 + #t + ("array" "of" "strings") + #hasheq((key-1 . null) (key-2 . #f) (key-3 . #hasheq((subkey . 21)))))) \ No newline at end of file diff --git a/beautiful-racket-demo/jsonic-demo/test-sources.rkt b/beautiful-racket-demo/jsonic-demo/test-sources.rkt index 8f8ad0b..26edbaa 100644 --- a/beautiful-racket-demo/jsonic-demo/test-sources.rkt +++ b/beautiful-racket-demo/jsonic-demo/test-sources.rkt @@ -1,11 +1,11 @@ #lang at-exp br -(require br/test rackunit) - -(check-equal? (run-source "jsonic-test.rkt") @string-append{ -[ - null, - 42, - true, - ["array","of","strings"], - {"key-2":false,"key-1":null,"key-3":{"subkey":21}} -]}) \ No newline at end of file +(require br/test rackunit json) + +;; don't compare string output directly because +;; hash element isn't converted in a reliable order +(check-equal? (string->jsexpr (run-source "jsonic-test.rkt")) + '(null + 42 + #t + ("array" "of" "strings") + #hasheq((key-1 . null) (key-2 . #f) (key-3 . #hasheq((subkey . 21)))))) \ No newline at end of file