private/lw-test-util.ss
(module lw-test-util mzscheme
  (require "loc-wrapper.ss")
  (provide normalize-lw)
  
  (define (normalize-lw lw)
    (define-values (min-line min-column) (find-min-line/col lw))
    (define (normalize/lw lw)
      (cond
        [(loc-wrapper? lw)
         (make-loc-wrapper (normalize/e (loc-wrapper-e lw))
                           (- (loc-wrapper-line lw) min-line)
                           (loc-wrapper-line-span lw)
                           (- (loc-wrapper-column lw) min-column)
                           (loc-wrapper-column-span lw)
                           (loc-wrapper-unq? lw)
                           (loc-wrapper-metafunction-name lw))]
        [else lw]))
    (define (normalize/e e)
      (cond
        [(symbol? e) e]
        [(string? e) e]
        [else (map normalize/lw e)]))
    (normalize/lw lw))
  
  (define (find-min-line/col lw)
    (define min-line #f)
    (define min-col #f)
    (define (find-min/lw lw)
      (when (loc-wrapper? lw)
        (set! min-line (if min-line
                           (min min-line (loc-wrapper-line lw))
                           (loc-wrapper-line lw)))
        (set! min-col (if min-col
                          (min min-col (loc-wrapper-column lw))
                          (loc-wrapper-column lw)))
        (find-min/e (loc-wrapper-e lw))))
    (define (find-min/e e)
      (cond
        [(symbol? e) (void)]
        [(string? e) (void)]
        [else (for-each find-min/lw e)]))
    (find-min/lw lw)
    (values min-line min-col)))