From 4ed851459e97be03418b1e92a5c07174e99bf28f Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 11 Aug 2022 22:45:12 -0700 Subject: [PATCH] convert input to txexpr-attr-value (closes #17) --- txexpr/base.rkt | 2 +- txexpr/test/tests.rkt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/txexpr/base.rkt b/txexpr/base.rkt index b6ccbfc..ec676f6 100644 --- a/txexpr/base.rkt +++ b/txexpr/base.rkt @@ -240,7 +240,7 @@ (define+provide+safe (attr-join tx key value) (txexpr? can-be-txexpr-attr-key? can-be-txexpr-attr-value? . -> . txexpr?) (define starting-values (string-split (attr-ref tx key ""))) - (attr-set tx key (string-join (append starting-values (list value)) " "))) + (attr-set tx key (string-join (append starting-values (list (->txexpr-attr-value value))) " "))) (define no-failure-result (gensym)) ; failure-result might be #false (define+provide+safe (attr-ref attrs-arg key [failure-result no-failure-result]) diff --git a/txexpr/test/tests.rkt b/txexpr/test/tests.rkt index 48865af..c21381a 100644 --- a/txexpr/test/tests.rkt +++ b/txexpr/test/tests.rkt @@ -233,6 +233,8 @@ (and (member '(foo "fraw") (get-attrs result)) (member '(zim "zam") (get-attrs result)) #t))) (check-txexprs-equal? (attr-join '(p ((foo "bar"))) 'foo "zam") '(p ((foo "bar zam")))) + (check-txexprs-equal? (attr-join '(tx ((foo "bar")) baz (p bin)) 'key 'val) + '(tx ((foo "bar") (key "val")) baz (p bin))) (check-true (let ([result (attr-join '(p ((foo "bar"))) 'zim "zam")]) (and (member '(foo "bar") (get-attrs result)) (member '(zim "zam") (get-attrs result)) #t)))