Simplify Racket test harness, which uncovers a bug in the test data
This commit is contained in:
parent
a849923c50
commit
9a04a46372
|
@ -38,98 +38,10 @@
|
|||
(struct person thing (name date-of-birth) #:prefab)
|
||||
(struct titled person (title) #:prefab)
|
||||
|
||||
(struct asymmetric (forward back))
|
||||
|
||||
(define samples-txt-expected
|
||||
(hash 'record1 (capture (discard))
|
||||
'record2 (observe (speak (discard) (capture (discard))))
|
||||
'list4a '(1 2 3 4)
|
||||
'list5 '(-2 -1 0 1)
|
||||
'string3 "hello"
|
||||
'list6 `("hello" there #"world" () ,(set) #t #f)
|
||||
'bytes2 #"hello"
|
||||
'bytes3 #"ABC"
|
||||
'bytes4 #"ABC"
|
||||
'bytes5 #"AJN"
|
||||
'bytes7 #"corymb"
|
||||
'bytes8 #"corymb"
|
||||
'bytes9 #"Hi"
|
||||
'bytes10 #"Hi"
|
||||
'bytes11 #"Hi"
|
||||
'value1 #"corymb"
|
||||
'value2 #t
|
||||
'value3 #t
|
||||
'value4 #t
|
||||
'value5 #t
|
||||
'value6 (list 1 2 3)
|
||||
'list0 '()
|
||||
'dict0 (hash)
|
||||
'string0 ""
|
||||
'symbol0 '||
|
||||
'set0 (set)
|
||||
'set1 (set 1 2 3)
|
||||
'set1a (set 1 2 3)
|
||||
'string4 "abc\u6c34\u6C34\\/\"\b\f\n\r\txyz"
|
||||
'bytes13 #"abc\x6c\x34\xf0\\/\"\b\f\n\r\txyz"
|
||||
'string5 "\U0001D11E"
|
||||
'record1 (capture (discard))
|
||||
'record2 (observe (speak (discard) (capture (discard))))
|
||||
'record3 (titled 101 "Blackwell" (date 1821 2 3) "Dr")
|
||||
'record4 (asymmetric (record 'discard '()) (discard))
|
||||
'record5 (record 7 '(()))
|
||||
'record6 (asymmetric (record 'discard '(surprise))
|
||||
'#s(discard surprise))
|
||||
'record7 (record "aString" '(3 4))
|
||||
'record8 (record (discard) '(3 4))
|
||||
'list7 (list 'abc '|...| 'def)
|
||||
'dict1 (hash 'a 1
|
||||
"b" #t
|
||||
'(1 2 3) #"c"
|
||||
(hash 'first-name "Elizabeth") (hash 'surname "Blackwell"))
|
||||
'rfc8259-example1 (hash "Image"
|
||||
(hash "Width" 800
|
||||
"Height" 600
|
||||
"Title" "View from 15th Floor"
|
||||
"Thumbnail" (hash "Url" "http://www.example.com/image/481989943"
|
||||
"Height" 125
|
||||
"Width" 100)
|
||||
"Animated" 'false
|
||||
"IDs" (list 116 943 234 38793)))
|
||||
'rfc8259-example2 (list (hash
|
||||
"precision" "zip"
|
||||
"Latitude" 37.7668
|
||||
"Longitude" -122.3959
|
||||
"Address" ""
|
||||
"City" "SAN FRANCISCO"
|
||||
"State" "CA"
|
||||
"Zip" "94107"
|
||||
"Country" "US")
|
||||
(hash
|
||||
"precision" "zip"
|
||||
"Latitude" 37.371991
|
||||
"Longitude" -122.026020
|
||||
"Address" ""
|
||||
"City" "SUNNYVALE"
|
||||
"State" "CA"
|
||||
"Zip" "94085"
|
||||
"Country" "US"))
|
||||
'annotation1 (asymmetric (annotate 9 "abc") 9)
|
||||
'annotation2 (asymmetric (annotate (list '() (annotate '() "x")) "abc" "def") '(() ()))
|
||||
'annotation3 (asymmetric (annotate 5 (annotate 2 1) (annotate 4 3)) 5)
|
||||
'annotation4 (asymmetric (hash (annotate 'a 'ak) (annotate 1 'av)
|
||||
(annotate 'b 'bk) (annotate 2 'bv))
|
||||
(hash 'a 1 'b 2))
|
||||
'annotation5 (asymmetric (annotate `#s(R ,(annotate 'f 'af)) 'ar) `#s(R f))
|
||||
'annotation6 (asymmetric (record (annotate 'R 'ar) (list (annotate 'f 'af))) `#s(R f))
|
||||
'annotation7 (asymmetric (annotate '() 'a 'b 'c) '())
|
||||
))
|
||||
|
||||
(define (run-test-case variety t-name loc binary-form annotated-text-form)
|
||||
(define text-form (strip-annotations annotated-text-form))
|
||||
(define-values (forward back can-execute-nondet-with-canonicalization?)
|
||||
(match (hash-ref samples-txt-expected t-name text-form)
|
||||
[(asymmetric f b) (values f b #f)] ;; #f because e.g. annotation4 includes annotations
|
||||
[v (values v v #t)]))
|
||||
(define forward text-form)
|
||||
(define back text-form)
|
||||
(check-equal? text-form back loc) ;; expectation 1
|
||||
(check-equal? (d-strip (preserve->bytes #:encode-embedded values text-form))
|
||||
back
|
||||
|
@ -157,11 +69,9 @@
|
|||
#:read-syntax? #t)
|
||||
annotated-text-form
|
||||
loc)
|
||||
(when (and (not (memq variety '(decode)))
|
||||
(or (not (memq variety '(nondeterministic)))
|
||||
(and can-execute-nondet-with-canonicalization?)))
|
||||
(when (not (memq variety '(decode)))
|
||||
;; expectations 9 and 10
|
||||
(check-equal? (preserve->bytes forward
|
||||
(check-equal? (preserve->bytes annotated-text-form
|
||||
#:encode-embedded values
|
||||
#:canonicalizing? #t
|
||||
#:write-annotations? #t)
|
||||
|
|
Loading…
Reference in New Issue