learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-22.scm (1164B)


      1 (define-library (sicp tests chapter-3 exercise-22)
      2   (import (scheme base))
      3   (import (scheme write))
      4   (import (srfi :64))
      5   (import (sicp solutions chapter-3 exercise-22))
      6 
      7   (begin
      8     (test-begin "chapter-3-exercise-22")
      9 
     10     (define (test-equal-print-queue string-ratsui queue-matsui)
     11       (define string-port (open-output-string))
     12 
     13       ((queue-matsui 'print-queue) string-port)
     14 
     15       (define string-matsui
     16         (get-output-string string-port))
     17 
     18       (test-equal string-ratsui string-matsui))
     19 
     20     (define q1 (make-queue))
     21     (test-equal-print-queue "()" q1)
     22 
     23     ((q1 'insert-queue!) 'a)
     24     (test-equal-print-queue "(a)" q1)
     25 
     26     ((q1 'insert-queue!) 'b)
     27     (test-equal-print-queue "(a b)" q1)
     28 
     29     ((q1 'insert-queue!) 'c)
     30     (test-equal-print-queue "(a b c)" q1)
     31 
     32     ((q1 'insert-queue!) 'd)
     33     (test-equal-print-queue "(a b c d)" q1)
     34 
     35     ((q1 'delete-queue!))
     36     (test-equal-print-queue "(b c d)" q1)
     37 
     38     ((q1 'delete-queue!))
     39     (test-equal-print-queue "(c d)" q1)
     40 
     41     ((q1 'delete-queue!))
     42     (test-equal-print-queue "(d)" q1)
     43 
     44     ((q1 'delete-queue!))
     45     (test-equal-print-queue "()" q1)
     46 
     47     (test-end "chapter-3-exercise-22")))