((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/srfi-78" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "SRFI-78" (p "The aim of lightweight testing is to provide a simple set of procedures for defining and running tests.") (p "The original SRFI documentation is available at: " (link "http://srfi.schemers.org/srfi-78/"))) (section 2 "Examples" (section 3 "check" (p (tt "(check ''expression'' => ''expected'')")) (p (tt "(check ''expected'' (=> ''predicate'') ''expected'')")) (p "Evaluates " (tt "expression") " and " (tt "expected") ", comparing the results using the given " (tt "predicate") " or " (tt "equal?") ", in the first case.  Then, depending on the current mode, a report will be printed and the counts of passed/failed tests updated.") (pre "> (check (+ 1 1) => 2)\n(+ 1 1)\n=>\n2\n;; correct\n> (check (list (+ 1 1) \"a b c\") \n         (=> (lambda (a b) (string=? (cadr a) (cadr b))))\n         (list (+ 2 1) \"a b c\"))\n\n(list (+ 1 1) \"a b c\")\n(=> (lambda (a b) (string=? (cadr a) (cadr b))))\n(2 \"a b c\")\n;; correct\n> (check (list (+ 1 1) \"a b c\") \n         (=> (lambda (a b) (string=? (cadr a) (cadr b)))) \n         (list 2 \"a b c d\")) \n\n(list (+ 1 1) \"a b c\")\n(=> (lambda (a b) (string=? (cadr a) (cadr b))))\n(2 \"a b c\")\n;; *** failed ***\n;; expected result: (2 \"a b c d\")")) (section 3 "check-ec" (p (tt "check-ec") " uses eager comprehensions, as in SRFI 42, to provide a form of automated bulk tested.  Therefore, you must import SRFI 42 before you can use this macro.") (p (tt "(check-ec ''qualifier'' ... ''expression'' => ''expected'')")) (p (tt "(check-ec ''qualifier'' ... ''expected'' (=> ''predicate'') ''expected'')")) (p (tt "(check-ec ''qualifier'' ... ''expression'' => ''expected'' (''argument'' ...))")) (p (tt "(check-ec ''qualifier'' ... ''expected'' (=> ''predicate'') ''expected'' (''argument'' ...))")) (p "The " (i "qualifer") " ... are one or more qualifiers, as defined in SRFI 42. Values for " (tt "expression") " and " (tt "expected") " are computed for each value of the qualifiers, and results compared.  The test stops as soon as one set of values fails to match.  The optional list of " (tt "argument") "s are variable names which can be printed in the event of a failed test.") (p "A simple example of bulk testing:") (pre "> (check-ec (: i 10) \n            (: j 10) \n            (: k 10) \n    (+ (* i j) (* i k)) \n    (=> =) \n    (* i (+ j k)))\n\n(check-ec (nested (: i 10) (: j 10) (: k 10))\n  (+ (* i j) (* i k)) (=> =) (* i (+ j k)) ())\n(=> =)\n<void>\n;; correct (1000 cases checked)") (p "An illustration of how variable names can be displayed in the event of an error (the variable value is given in the " (tt "let") " form):") (pre "> (check-ec (: e 100) \n            (:let x (expt 2.0 e)) \n    (= (+ x 1) x) \n    => \n    #f (x))\n(let ((x 9.007199254740992e15)) (= (+ x 1) x))\n=>\n#t\n;; *** failed ***\n;; expected result: #f") (p "The following example sets up a list of input and expected output values:") (pre "> (check-ec (: i '((1 1) (2 4) (3 9) (4 16))) \n        (* (car i) (car i)) \n        =>\n        (cadr i))\n\n(check-ec (: i '((1 1) (2 4) (3 9) (4 16)))\n  (* (car i) (car i)) (=> equal?) (cadr i) ())\n=>\n<void>\n;; correct (4 cases checked)")) (section 3 "check-passed?" (p (tt "(check-passed? ''expected-total'') -> ''boolean''")) (p "Compares the actual number of passed tests so far with the given expected number, returning " (tt "#t") " if they are equal and " (tt "#f") " if not.")) (section 3 "check-report" (p (tt "(check-report)")) (p "Depending on the current mode, this prints a report and the first failed test (if any).") (pre "> (check-report)\n\n;; *** checks *** : 1 correct, 1 failed. First failed example:\n\n(+ 1 1)\n=>\n2\n;; *** failed ***\n;; expected result: 2.0")) (section 3 "check-reset!" (p (tt "(check-reset!)")) (p "Resets the counter of numbers of tests passed/failed.  (This may be used to display multiple reports for different parts of the code.)")) (section 3 "check-set-mode!" (p (tt "(check-set-mode! ''mode'') -> unspecified")) (p "Changes the current mode to one of the following:") (ul (li (tt "off") ": do not execute any of the checks") (li (tt "summary") ": print only summary in " (tt "check-report") " and nothing else") (li (tt "report-failed") ": report failed checks when they happen, and in summary") (li (tt "report") ": report every example executed")) (p "The default is " (tt "report")))) (section 2 "Authors" (p "SRFI 78 was written by Sebastian Egner, and this port to Chicken was made by " (int-link "/users/peter-lane" "Peter Lane") ".")) (section 2 "License" (p "Released under a SRFI license.")) (section 2 "Requirements" (p "To use " (tt "check-ec") " you will also need srfi-42 installed.")) (section 2 "Version History" (p "version 1.0: first package.")))