From 610666cbce9acaa1ee71cecc29dbdc526fa3b861 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 31 Dec 2015 12:15:12 -0800 Subject: [PATCH] improve further --- main.rkt | 4 +++- tests.rkt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main.rkt b/main.rkt index 664c175..2644844 100644 --- a/main.rkt +++ b/main.rkt @@ -141,7 +141,9 @@ (validate-txexpr-attrs-with-context (get-attrs x)) (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)] [(and (list? x) (symbol? (car x))) - (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x))] + (and + (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) + (validate-txexpr-attrs-with-context (get-attrs x)))] [(list? x) (error 'validate-txexpr (format "~v is a list but it doesn't start with a symbol" x))] [else (error 'validate-txexpr (format "~v: not an X-expression" x))])) diff --git a/tests.rkt b/tests.rkt index 57f20dd..2ba1d8b 100644 --- a/tests.rkt +++ b/tests.rkt @@ -70,6 +70,7 @@ (check-exn exn:fail? (λ _ (validate-txexpr "foo"))) ; not a list with symbol (check-exn exn:fail? (λ _ (validate-txexpr '(p "foo" "bar" ((key "value")))))) ; malformed (check-exn exn:fail? (λ _ (validate-txexpr '("p" "foo" "bar")))) ; no name + (check-exn exn:fail? (λ _ (validate-txexpr '(root ((id "top")(class 42)))))) ; malformed attrs (check-txexprs-equal? (make-txexpr 'p) '(p))