improve further

dev-fixit
Matthew Butterick 9 years ago
parent fd17224249
commit 610666cbce

@ -141,7 +141,9 @@
(validate-txexpr-attrs-with-context (get-attrs x)) (validate-txexpr-attrs-with-context (get-attrs x))
(andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)] (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)]
[(and (list? x) (symbol? (car 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))] [(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))])) [else (error 'validate-txexpr (format "~v: not an X-expression" x))]))

@ -70,6 +70,7 @@
(check-exn exn:fail? (λ _ (validate-txexpr "foo"))) ; not a list with symbol (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" ((key "value")))))) ; malformed
(check-exn exn:fail? (λ _ (validate-txexpr '("p" "foo" "bar")))) ; no name (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)) (check-txexprs-equal? (make-txexpr 'p) '(p))

Loading…
Cancel
Save