#lang racket/base (require sugar/define racket/match "base.rkt" rackunit) (define (stringify-attr attr) (match attr [(list key val) (string-append (symbol->string key) val)])) (define (sort-attrs x) (match x [(? txexpr?) (let-values ([(tag attr elements) (txexpr->values x)]) (txexpr tag (sort attr #:key stringify-attr #:cache-keys? #t string . boolean?) (apply txexprs-equal? (map (λ (x) `(_ ,(if (txexpr-attrs? x) x (get-attrs x)))) (list x1 x2)))) (provide+safe check-txexprs-equal?) (define-simple-check (check-txexprs-equal? tx1 tx2) (txexprs-equal? tx1 tx2)) (module+ test (check-txexprs-equal? '(p ((b "foo")(a "bar")) (span ((d "foo")(c "bar")))) '(p ((a "bar")(b "foo")) (span ((c "bar")(d "foo"))))) ;; two attrs with same key (check-txexprs-equal? '(p ((a "foo")(a "bar"))) '(p ((a "bar")(a "foo")))))