Unexpected Behaviour of `should=`
Good morning.
I am self-learning Guile with "Structure and Interpretation of Computer Programs" book. At the same, I am trying to get into the habit of Test Driven Development. I discovered this project and decided to use it instead of wrestling with SRFI-64 and its log files.
I was able to write tests without any issues until I arrived at chapter "Representing Sequences". I wrote some tests first, wrote the code and cycled through some rewrites until I got a really unexpected failure.
Please have a look at the following test output and the corresponding source file. To my untrained eyes, all of the tests should succeed here.
Representing Sequences
- Chapter
FAIL Example 1
expected-value: (1 2 3 4)
actual-value: (1 2 3 4)
PASS Example 2
PASS Example 3
; DIMENSION 0
; Chapter
( define example-1
( cons
1
( cons
2
( cons 3 [ cons 4 #nil ] ) ) ) )
( define one-through-four
( list 1 2 3 4 ) )
; DIMENSION 1
; Chapter
( define example-2
( car one-through-four ) )
( define example-3
( cdr one-through-four ) )
( define example-4
( car ( cdr one-through-four ) ) )
( define example-5
( cons 10 one-through-four ) )
( define example-6
( cons 5 one-through-four ) )
; TESTS
( use-modules [ spec ] )
( install-spec-runner-term )
( describe "Representing Sequences"
( context "Chapter"
( it "Example 1" ( should= ( list 1 2 3 4 ) example-1 ) )
( it "Example 2"
( should
( and
[ = 1 ( list-ref one-through-four 0 ) ]
[ = 2 ( list-ref one-through-four 1 ) ]
[ = 3 ( list-ref one-through-four 2 ) ]
[ = 4 ( list-ref one-through-four 3 ) ] ) ) )
( it "Example 3"
( should
( and
[ = 1 example-2 ]
[ equal? '( 2 3 4 ) example-3 ]
[ = 2 example-4 ]
[ equal? '( 10 1 2 3 4 ) example-5 ]
[ equal? '( 5 1 2 3 4 ) example-6 ] ) ) ) ) ) )