convert input to txexpr-attr-value (closes #17)

master
Matthew Butterick 2 years ago
parent 037e280e34
commit 4ed851459e

@ -240,7 +240,7 @@
(define+provide+safe (attr-join tx key value) (define+provide+safe (attr-join tx key value)
(txexpr? can-be-txexpr-attr-key? can-be-txexpr-attr-value? . -> . txexpr?) (txexpr? can-be-txexpr-attr-key? can-be-txexpr-attr-value? . -> . txexpr?)
(define starting-values (string-split (attr-ref tx key ""))) (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 no-failure-result (gensym)) ; failure-result might be #false
(define+provide+safe (attr-ref attrs-arg key [failure-result no-failure-result]) (define+provide+safe (attr-ref attrs-arg key [failure-result no-failure-result])

@ -233,6 +233,8 @@
(and (member '(foo "fraw") (get-attrs result)) (and (member '(foo "fraw") (get-attrs result))
(member '(zim "zam") (get-attrs result)) #t))) (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 '(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")]) (check-true (let ([result (attr-join '(p ((foo "bar"))) 'zim "zam")])
(and (member '(foo "bar") (get-attrs result)) (and (member '(foo "bar") (get-attrs result))
(member '(zim "zam") (get-attrs result)) #t))) (member '(zim "zam") (get-attrs result)) #t)))

Loading…
Cancel
Save