From aa452d74c2ad17fce5d04d5a0548bc9ac39c7704 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 11 Dec 2015 12:25:22 -0800 Subject: [PATCH] adjust sorting in `check-txexprs-equal?` --- main.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.rkt b/main.rkt index 0437e6e..96847d4 100644 --- a/main.rkt +++ b/main.rkt @@ -348,12 +348,17 @@ ;; txexprs are deemed equal if they differ only in the ordering of attributes. ;; therefore, to check them, 1) sort their attributes, 2) straight list comparison. ;; use letrec because `define-simple-check` wants an expression in <=6.2 - (letrec ([symbolstring syms)))] + + ;; `stringify-attr` is needed because comparing attr keys won't work if there are two attrs with same key. + ;; so the whole attr is converted into a single string for sorting, which lets the attr value act as a tiebreaker. + (letrec ([stringify-attr (λ(attr) (string-append (symbol->string (car attr)) (cadr attr)))] [sort-attrs (λ(x) (if (txexpr? x) (let-values ([(tag attr elements) (txexpr->values x)]) - (make-txexpr tag (sort attr #:key car symbol