peterhil/btrie — pull request #2 by appleby (2014-04-11 01:26:37+00:00)
Title: Fixes for print-words and nodes-equalp

Respect the optional STREAM argument in `print-words`, rather than always printing to `*standard-ouput*`.

Also, recursively check that a node's branches are equal in `nodes-equalp`, and fix a couple of failing unit tests.

Please ignore the previous pull request, as this pull request contains that commit as well.

## Before nodes-equalp fixes
BTRIE-TESTS> (run-tests :suite 'btrie-tests)
Start: BTRIE-TESTS
Start: BTRIE-LOOKUP
Start: TEST-OBTAIN-SEQ
Start: BTRIE-PREDICATES
Start: TEST-NODES-EQUALP
Start: TEST-INIT
#

BTRIE-TESTS> (describe *)
Test Report for BTRIE-TESTS: 4 tests run, 3 Failures.

Failure: test-obtain-seq : simple-lookup

Condition : Ensure-same: (a 1 .) is not NODES-EQUALP to (a 1 .)
During : END-TEST
Code :
((LET ((TR (MAKE-TRIE *BANANA*)))
(WITH-SLOTS ((K KEY) (W WIDTH) (B BRANCHES))
(LET ((RESULT-NODE))
(ENSURE-SAME (OBTAIN-SEQ TR "banana")
(MAKE-NODE :KEY #\a :WIDTH 1 :BRANCHES
(LIST (MAKE-LEAF)))
:TEST #'NODES-EQUALP)))))

Failure: test-nodes-equalp : leaf-nodes

Condition : Ensure-same: (. 1 is not equal to (. 1
During : END-TEST
Code :
((ENSURE-SAME #1=(MAKE-LEAF) #1#))

Failure: test-nodes-equalp : empty-tries

Condition : Ensure-same: ("" 0 is not equal to ("" 0
During : END-TEST
Code :
((ENSURE-SAME #1=(MAKE-TRIE) #1#))

Test Report for BTRIE-TESTS: 4 tests run, 3 Failures.
; No value

## After nodes-equalp fixes
BTRIE-TESTS> (run-tests :suite 'btrie-tests)
Start: BTRIE-TESTS
Start: BTRIE-LOOKUP
Start: TEST-OBTAIN-SEQ
Start: BTRIE-PREDICATES
Start: TEST-NODES-EQUALP
Start: TEST-INIT
#

## Before print-words fix

BTRIE-TESTS> (run-tests)

Start: TEST-PRINT-WORDSc
as
an
ar
are
b
barn
bar
bare
ban
bane
banana
#

BTRIE-TESTS> (describe *)
Test Report for TEST-PRINT-WORDS: 1 test run, 1 Failure.

Failure: test-print-words : print-to-stream

Condition : Ensure-same: "c
as
an
ar
are
b
barn
bar
bare
ban
bane
banana
" is not STRING= to ""
During : END-TEST
Code :
((LET ((TR (MAKE-TRIE *BANANA*)))
(ENSURE-SAME
(WITH-OUTPUT-TO-STRING (STD-OUT-STREAM)
(LET ((*STANDARD-OUTPUT* STD-OUT-STREAM))
(PRINT-WORDS TR)))
(WITH-OUTPUT-TO-STRING (USER-SUPPLIED-STREAM)
(PRINT-WORDS TR USER-SUPPLIED-STREAM))
:TEST #'STRING=)))

Test Report for TEST-PRINT-WORDS: 1 test run, 1 Failure.
; No value

## After print-words fix

BTRIE-TESTS> (run-tests :suite 'btrie-tests)
Start: BTRIE-TESTS
Start: BTRIE-TRAVERSAL-AND-PRINTING
Start: TEST-PRINT-WORDS
Start: BTRIE-LOOKUP
Start: TEST-OBTAIN-SEQ
Start: BTRIE-PREDICATES
Start: TEST-NODES-EQUALP
Start: TEST-INIT
#