check-sexp-equal
check-sexp-equal?
8.12

check-sexp-equal🔗ℹ

 (require check-sexp-equal) package: check-sexp-equal

check-equal? doesn’t even pretty-print the sexprs on failure, which can be very long and hard to compare. Anyway let’s do even better and use sexp-diff to highlight to diff.

procedure

(check-sexp-equal? a b)  (void)

  a : any/c
  b : any/c
Like check-equal? but on failure reports using sexp-diff so you can more easily see structural differences at any level.

The original check-equal with a complex structure, on failure:

(let ([a '(a (foo bar foo bar b c d e f (g h i j k l))
             (m n o p q (r s t u v w x y z)))]
        [b '(a (foo bar foo bar b c d e f (g h i j k l))
             (m n o p q (r s t u v 0 x y z)))])
    (check-equal? a b))

outputs:

FAILURE

actual:     (a (foo bar foo bar b c d e f (g h i j k l)) (m n o p q (r s t u v w x y z)))

expected:   (a (foo bar foo bar b c d e f (g h i j k l)) (m n o p q (r s t u v 0 x y z)))

name:       check-equal?

location:   (#<path:/Users/ryan/Work/git/zenspider/check-sexp-equal/main.rkt> 22 4 713 18)

expression: (check-equal? a b)

 

Check failure

But switching from check-equal? to check-sexp-equal? outputs:

FAILURE

name:       check-sexp-equal?

location:   (#<path:/Users/ryan/Work/git/zenspider/check-sexp-equal/main.rkt> 28 4 926 23)

expression: (check-sexp-equal? a b)

params:     ((a (foo bar foo bar b c d e f (g h i j k l)) (m n o p q (r s t u v w x y z))) (a (foo bar foo bar b c d e f (g h i j k l)) (m n o p q (r s t u v 0 x y z))))

 

sexp-diff (#:new = actual, #:old = expected):

 

'((a

   (foo bar foo bar b c d e f (g h i j k l))

   (m n o p q (r s t u v #:new w #:old 0 x y z))))