Don't count singleton sub-tests as a separate level.
authorChris Hanson <org/chris-hanson/cph>
Mon, 28 Sep 2009 03:53:07 +0000 (20:53 -0700)
committerChris Hanson <org/chris-hanson/cph>
Mon, 28 Sep 2009 03:53:07 +0000 (20:53 -0700)
tests/unit-testing.scm

index 73a50a4c2ae4f532c596ca147d974f30938b4a1d..8620e4f4d810024388ad152f4e779e115e6e823d 100644 (file)
@@ -75,16 +75,20 @@ USA.
   (cons (car td)
        (reverse!
         (let loop ((test (cdr td)) (name "") (results '()))
-          (if (thunk? test)
-              (cons (cons name (run-test-thunk test))
-                    results)
-              (do ((tests test (cdr tests))
-                   (index 0 (+ index 1))
-                   (results results
-                            (loop (car tests)
-                                  (string name "." index)
-                                  results)))
-                  ((not (pair? tests)) results)))))))
+          (cond ((thunk? test)
+                 (cons (cons name (run-test-thunk test))
+                       results))
+                ((and (pair? test)
+                      (null? (cdr test)))
+                 (loop (car test) name results))
+                (else
+                 (do ((tests test (cdr tests))
+                      (index 0 (+ index 1))
+                      (results results
+                               (loop (car tests)
+                                     (string name "." index)
+                                     results)))
+                     ((not (pair? tests)) results))))))))
 
 (define (run-test-thunk thunk)
   (call-with-current-continuation