;; demo-interfaces
;; Demonstrates the use of the various user interfaces for SchemeUnit.
;; Define ui to be one of 'graphical, or 'text to use that
;; user interface. For the text and graphical UIs, run the tests by clicking
;; the Execute button.

(require ""

(define ui 'graphical)

(define test/chosen-ui
  (case ui
    ([graphical] test/graphical-ui)
    ([text] test/text-ui)))

 (make-test-suite "Various tests"
   (make-test-case "A solitary test case"
     (assert-equal? 'apple (string->symbol "apple")))
   (make-test-suite "An empty test suite")
   (make-test-suite "All of these should be red"
     (make-test-case "This case should fail"
         (+ 47
            (if (zero? 2)
                (* 8 9)
                (assert-equal? 4 5)))
     (make-test-case "Another failure, on a primitive function"
       (assert-pred positive? (* 13 -1)))
     (make-test-case "Doesn't work, either"
       (assert = 1 2))
     (make-test-case "Failure of anonymous predicate"
        (lambda (x) #f)
     (make-test-case "This causes error"
       (cons 4))
     (make-test-suite "A nested suite"
       (make-test-case "Fine" 
         (and (assert-equal? 4 (sub1 5)) 
              (assert-eq? 'hi 'hi)))
       (make-test-case "Not fine"
         (assert-exn (lambda _ #f) 
                     (lambda () (error 'test "look over there!"))))
       (make-test-case "Subtle (error)"
          (lambda _ #f)
          (error 'test "I'm evaluated *before* assert-exn is applied")))
       (make-test-case "Flat fail" (fail)))
     (make-test-case "Another error (causes output)"
         (printf "Here's some output")
         (fprintf (current-error-port) "talking to error port")
         (printf " which will probably be interleaved and all")
         (fprintf (current-error-port)
                  "(but at least it should be marked properly).")
         (error 'whoa "made a mistake")))
     (make-test-case "Error with interesting backtrace"
       (let [(foo (+ 3 (/ 1 0)))]
     (make-test-case "Weird"
         (let [(cms (current-continuation-marks))]
           (raise (make-exn "gotcha" cms)))
     (make-test-case "Raise non-exn-struct"
       (raise 'not-an-exn))