Changeset 38278 in project


Ignore:
Timestamp:
03/16/20 16:03:29 (2 weeks ago)
Author:
juergen
Message:

simple-tests 2.0 docu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/simple-tests

    r37985 r38278  
    88Seibel's test suite in "Practical Common Lisp" to Chicken Scheme.
    99
    10 === The routines
     10=== Common
    1111
    1212==== simple-tests
     
    1616documentation-procedure; returns the list of exported symbols if called
    1717with no symbol, otherwise the signature of that exported symbol sym.
     18
     19==== and?
     20
     21<procedure>(and? xpr . xprs)</procedure>
     22
     23non-short-circuated and, which executes all side-effects.
     24
     25==== writeln
     26
     27<procedure>(writeln xpr . xprs)</procedure>
     28
     29like print, but writes expressions separated by a space in one line.
     30
     31==== pe
     32
     33<procedure>(pe macro-code)</procedure>
     34
     35pretty-prints expanded macro-code.
     36
     37==== xpr:val
     38
     39<macro>(xpr:val xpr ...)</macro>
     40
     41print each xpr quoted in a headline and pretty-print its computed value.
     42
     43==== ppp
     44
     45<macro>(ppp xpr ...)</macro>
     46
     47print each xpr quoted in a headline and pretty-print its computed value,
     48alias to xpr:val
     49
     50==== ppp*
     51
     52<macro>(ppp* {xpr val} ...)</macro>
     53
     54print each xpr quoted in a headline, and pretty-print xpr's computed as well as
     55its expected value.
     56
     57==== xpr:val*
     58
     59<macro>(xpr:val* {xpr val} ...)</macro>
     60
     61alias to ppp*
     62
     63=== Old interface
    1864
    1965==== compound-test
     
    3480its form arguments.
    3581
    36 ==== xpr:val
    37 
    38 <macro>(xpr:val xpr ...)</macro>
    39 
    40 print each xpr quoted in a headline and pretty-print its computed value.
    41 
    42 ==== ppp
    43 
    44 <macro>(ppp xpr ...)</macro>
    45 
    46 print each xpr quoted in a headline and pretty-print its computed value,
    47 alias to xpr:val
    48 
    49 ==== ppp*
    50 
    51 <macro>(ppp* {xpr val} ...)</macro>
    52 
    53 print each xpr quoted in a headline, and pretty-print xpr's computed as well as
    54 its expected value.
    55 
    56 ==== and?
    57 
    58 <procedure>(and? xpr . xprs)</procedure>
    59 
    60 non-short-circuated and, which executes all side-effects.
    61 
    62 ==== pe
    63 
    64 <procedure>(pe macro-code)</procedure>
    65 
    66 pretty-prints expanded macro-code.
    67 
    6882==== *locations*
    6983
     
    7488global variable collecting failure information
    7589
    76 === Example
     90=== New interface
     91
     92==== ==
     93
     94<procedure>(==)</procedure>
     95<procedure>(== x)</procedure>
     96<procedure>(== type? type-equal?)</procedure>
     97
     98generic procedure.
     99The first resets the local database,
     100the second returns the curried equality operator, corresponding to x,
     101and the third adds a new pair to the local database.
     102Using (== x) for comparison, you needn't supply a special comparison
     103operator, (== x) will do it for you.
     104
     105==== define-checks
     106
     107<macro>(define-checks (name? verbose? {arg val} ...) {xpr expected} ...)</macro>
     108
     109defines a unary predicate, name?, with argument verbose?, which compares
     110all pairs {xpr expected} and prints a list of failures, if verbose? is
     111#t.  Otherwise simply returns #t of #f, depending on the comparison of
     112the pairs' items.
     113Comparison is done by the generic procedure ==.
     114{arg val} ... is translated into a let,  supplying values to be used in test pairs.
     115The verbose? argument is usually #t, but #f for check-procedures within
     116check-procedures, cf. arithmetic? below.
     117
     118==== check-all
     119
     120<macro>(check-all name check ...)</macro>
     121
     122tests each check in sequence and names it.
     123
     124=== Examples
    77125
    78126<enscript highlight=scheme>
    79127
    80 (require-library simple-tests)
    81128(import simple-tests)
    82129
     
    96143  (arithmetic?))
    97144
     145or, ALTERNATIVELY
     146
     147(define-checks (+? verbose?)
     148  (+ 1 2) 3
     149  (+ 1 2 3) 6)
     150
     151(define-checks (*? verbose?)
     152  (* 1 2) 2
     153  (* 1 2 3) 6)
     154
     155(define-checks (arithmetic? verbose?)
     156  (+? #f) #t
     157  (*? #f) #t)
     158
     159(check-all SIMPLE (+? #t) (*? #t) (arithmetic? #t))
     160
    98161</enscript>
    99162
    100163== Last update
    101164
    102 Nov 08, 2019
     165Mar 15, 2020
    103166
    104167== Author
     
    108171== License
    109172
    110  Copyright (c) 2013-2019, Juergen Lorenz
     173 Copyright (c) 2013-2020, Juergen Lorenz
    111174 All rights reserved.
    112175
     
    139202== Version History
    140203
     204; 2.0 : added a second testing interface
    141205; 1.1 : ppp* added
    142206; 1.0 : port with modifications from chicken-4, version 2.6, to chicken-5
Note: See TracChangeset for help on using the changeset viewer.