Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Chap13
README.shen
TinyLispFunctions.txt
TinyTypes.shen
binary.shen
bubble version 1.shen
bubble version 2.shen
calculator.shen
cartprod.shen
change.shen
classes-defaults.shen
classes-inheritance.shen
classes-typed.shen
classes-untyped.shen
depth'.shen
einstein.shen
fruit machine.shen
interpreter.shen
metaprog.shen
minim.shen
mutual.shen
n queens.shen
newton version 1.shen
newton version 2.shen
parse.prl
parser.shen
powerset.shen
prime.shen
prolog.shen
proof assistant.shen
proplog version 1.shen
proplog version 2.shen
qmachine.shen
red-black.shen
search.shen
semantic net.shen
spreadsheet.shen
stack.shen
streams.shen
strings.shen
structures-typed.shen
structures-untyped.shen
tests.shen
types.shen
whist.shen
yacc.shen

README.shen

\*     					Standard Test Suite 1.0

This is the test harness for Shen.  Assuming your port to Blub is in the directory Platforms/Blub; do the
following.

(cd "../../Test Programs")
(load "README.shen")
(load "tests.shen")

*\

(package test-harness [report reset ok passed failed]

(define reset
  -> (set *passed* (set *failed* 0)))

(defmacro exec-macro
  [exec Name Expr Prediction]
  -> [trap-error [let (protect Output) [output "~%~A: ~R = ~S" Name (rcons Expr) Prediction]
                   (protect Result) [time Expr]
                   [if [= (protect Result) Prediction]
                       [passed]
                       [failed (protect Result)]]]
                 [/. (protect E) [err (protect E)]]])

(define rcons
  [X | Y] -> [cons (rcons X) (rcons Y)]
  X -> X)

(define passed
  -> (do (trap-error
          (set *passed* (+ 1 (value *passed*)))
          (/. E (set *passed* 1)))
         (print passed)))

(define failed
  Result -> (let Fail+ (trap-error
                        (set *failed* (+ 1 (value *failed*)))
                        (/. E (set *failed* 1)))
                 ShowResult (output "~S returned~%" Result)
              (if (y-or-n? "failed; continue?") ok (error "kill"))))

(define err
  E -> (error "")  where (= (error-to-string E) "kill")
  E -> (do (trap-error
            (set *failed* (+ 1 (value *failed*)))
            (/. E (set *failed* 1)))
           (output "~%failed with error ~A~%" (error-to-string E))))

(defmacro report-results-macro
  [report Name | Tests] -> (let NewTests (create-tests Name Tests)
                             [do | NewTests]))

(define create-tests
  Name [] -> [[results] ok]
  Name [Test Prediction | Tests] -> [[exec Name Test Prediction] | (create-tests Name Tests)])

(define results
  -> (let Passed (trap-error (value *passed*) (/. E 0))
          Failed (trap-error (value *failed*) (/. E 0))
          Percent (* (/ Passed (+ Passed Failed)) 100)
       (output "~%passed ... ~A~%failed ...~A~%pass rate ...~A%~%~%"
               Passed Failed Percent))))