Thank you Mike for the link. I will certainly investigate more about this topic. For the moment I am applying a very simple approach which only checks the results:

`;; simple test cases`

(define TestResult)

(define tmpTestResult)

(define FailedCases)

(define Counter 0)

(define CheckResult

(lambda (num TestResult Expected)

(if (equal? TestResult Expected )

(begin (for-each display (list "Test: " num " ok ")))

;else

(begin

(for-each display (list "Test: " num ", Result: " TestResult " Expected: " Expected))

(newline)

(set! Counter (+ Counter 1))

(set! FailedCases (append FailedCases (list num TestResult Expected))))

)))

(define ReportFailures

(lambda (Counter)

(if (= 0 Counter)

(display "All Tests passed OK")

;else

(begin

(display Counter) (display " Test(s) failed")

(newline)

(display FailedCases)

(newline)

))))

;;; lambda

;;;; syntax: (lambda formals body)

;1

(set! tmpTestResult `,(lambda (x) (+ x x))) ;(CheckResult 1 TestResult `"#<CLOSURE>" )

(set! TestResult `,(closure? tmpTestResult)) (CheckResult 1 TestResult `#t )

;2

(set! TestResult `,((lambda (x) (+ x x)) 4)) (CheckResult 2 TestResult 8 )

;3

(define reverse-subtract

(lambda (x y) (- y x)))

(set! TestResult `,(reverse-subtract 7 10)) (CheckResult 3 TestResult 3 )

;4

(define add4

(let ((x 4))

(lambda (y) (+ x y))))

(set! TestResult `,(add4 6)) (CheckResult 4 TestResult 10 )

;5

(set! TestResult `,((lambda x x)

3 4 5 6)) (CheckResult 5 TestResult '(3 4 5 6) )

;6

(set! TestResult `,((lambda (x y . z) z)

3 4 5 6)) (CheckResult 6 TestResult '(5 6) )

;7

(set! TestResult `,(= 10 0)) (CheckResult 7 TestResult `#f)

;Test function

;8

(define factorial

(lambda (n)

(let fact ((i n))

(if (= i 0)

1

(* i (fact (- i 1)))))))

(set! TestResult `,(factorial 12)) (CheckResult 8 TestResult 479001600 )

(newline)

(ReportFailures Counter)

(newline)

(display "End of tests")

When I know more about Scheme I would like to format the output of failed cases.

I noticed that miniscm.c of my reply #44 does not work correctly with applying the 'do' macro due to a missing gensym procedure. Therefore I added OP_GENSYM and autogen() of o2scm.o2bas and updated the attachment of reply #44. I have also created a msinit.scm with some more definitions, as miniscm does not include all the capabilities of o2scm. But it is interesting to compare miniscm.c with o2scm.o2bas and see all the items which are missing.