Annotation inappropriate for ExpectedPlaceholderMapping

This commit is contained in:
Tony Garnock-Jones 2019-08-23 09:58:30 +01:00
parent a7147fa123
commit 6f4e06f6b9
2 changed files with 273 additions and 273 deletions

View File

@ -992,19 +992,17 @@
(define-runtime-path tests-path "../../../tests") (define-runtime-path tests-path "../../../tests")
(let* ((path (build-path tests-path "samples.txt")) (let* ((path (build-path tests-path "samples.txt"))
(tests (call-with-input-file path (testfile (call-with-input-file path
(lambda (p) (lambda (p)
(port-count-lines! p) (port-count-lines! p)
(read-preserve-syntax p #:source path))))) (read-preserve-syntax p #:source path)))))
(local-require racket/pretty) (match-define (peel-annotations
(define placeholder->value-map `#s(TestCases
(or (for/or [(a* (annotated-annotations tests))] ,(strip-annotations
(match (strip-annotations a*) `#s(ExpectedPlaceholderMapping ,placeholder->value-map))
[`#s(ExpectedPlaceholderMapping ,p->v) p->v] ,tests))
[_ #f])) testfile)
(hash))) (define value->placeholder-map (for/hash [((k v) (in-hash placeholder->value-map))]
(define value->placeholder-map
(for/hash [((k v) (in-hash placeholder->value-map))]
(values v k))) (values v k)))
(parameterize (parameterize
((current-value->placeholder (lambda (v) (hash-ref value->placeholder-map v #f))) ((current-value->placeholder (lambda (v) (hash-ref value->placeholder-map v #f)))

View File

@ -1,10 +1,11 @@
@<EmacsMode "-*- preserves -*-"> @<EmacsMode "-*- preserves -*-">
@<ExpectedPlaceholderMapping { <TestCases
<ExpectedPlaceholderMapping {
0: discard 0: discard
1: capture 1: capture
2: observe 2: observe
}> }>
{ {
annotation1: <Test #hex{055361626339} @"abc" 9> annotation1: <Test #hex{055361626339} @"abc" 9>
annotation2: <Test #hex{05536162630553646566929005517890} @"abc" @"def" [[] @"x" []]> annotation2: <Test #hex{05536162630553646566929005517890} @"abc" @"def" [[] @"x" []]>
annotation3: <Test #hex{050531320505333435} @@1 2 @@3 4 5> annotation3: <Test #hex{050531320505333435} @@1 2 @@3 4 5>
@ -207,7 +208,7 @@
42 03af 42 03af
42 00ea 42 00ea
43 009789} 43 009789}
{ {
"Image": { "Image": {
"Width": 800, "Width": 800,
"Height": 600, "Height": 600,
@ -220,7 +221,7 @@
"Animated" : false, "Animated" : false,
"IDs": [116, 943, 234, 38793] "IDs": [116, 943, 234, 38793]
} }
}> }>
rfc8259-example2: <NondeterministicTest rfc8259-example2: <NondeterministicTest
#hex{92 bf10 58 4c61746974756465 03 4042e226809d4952 #hex{92 bf10 58 4c61746974756465 03 4042e226809d4952
@ -239,7 +240,7 @@
55 5374617465 52 4341 55 5374617465 52 4341
53 5a6970 55 3934303835 53 5a6970 55 3934303835
54 43697479 59 53554e4e5956414c45} 54 43697479 59 53554e4e5956414c45}
[ [
{ {
"precision": "zip", "precision": "zip",
"Latitude": 37.7668, "Latitude": 37.7668,
@ -260,6 +261,7 @@
"Zip": "94085", "Zip": "94085",
"Country": "US" "Country": "US"
} }
]> ]>
} }
>