Hex Artifact Content
Not logged in

Artifact 4c4d8e0ab7c63f284b434cee28113a0269256019:


0000: 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 28 63 29  ;; Copyright (c)
0010: 20 32 30 30 39 20 44 65 72 69 63 6b 20 45 64 64   2009 Derick Edd
0020: 69 6e 67 74 6f 6e 2e 20 20 41 6c 6c 20 72 69 67  ington.  All rig
0030: 68 74 73 20 72 65 73 65 72 76 65 64 2e 0a 3b 3b  hts reserved..;;
0040: 20 4c 69 63 65 6e 73 65 64 20 75 6e 64 65 72 20   Licensed under 
0050: 61 6e 20 4d 49 54 2d 73 74 79 6c 65 20 6c 69 63  an MIT-style lic
0060: 65 6e 73 65 2e 20 20 4d 79 20 6c 69 63 65 6e 73  ense.  My licens
0070: 65 20 69 73 20 69 6e 20 74 68 65 20 66 69 6c 65  e is in the file
0080: 0a 3b 3b 20 6e 61 6d 65 64 20 4c 49 43 45 4e 53  .;; named LICENS
0090: 45 20 66 72 6f 6d 20 74 68 65 20 6f 72 69 67 69  E from the origi
00a0: 6e 61 6c 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 74  nal collection t
00b0: 68 69 73 20 66 69 6c 65 20 69 73 20 64 69 73 74  his file is dist
00c0: 72 69 62 75 74 65 64 0a 3b 3b 20 77 69 74 68 2e  ributed.;; with.
00d0: 20 20 49 66 20 74 68 69 73 20 66 69 6c 65 20 69    If this file i
00e0: 73 20 72 65 64 69 73 74 72 69 62 75 74 65 64 20  s redistributed 
00f0: 77 69 74 68 20 73 6f 6d 65 20 6f 74 68 65 72 20  with some other 
0100: 63 6f 6c 6c 65 63 74 69 6f 6e 2c 20 6d 79 0a 3b  collection, my.;
0110: 3b 20 6c 69 63 65 6e 73 65 20 6d 75 73 74 20 61  ; license must a
0120: 6c 73 6f 20 62 65 20 69 6e 63 6c 75 64 65 64 2e  lso be included.
0130: 0a 0a 23 21 72 36 72 73 0a 28 6c 69 62 72 61 72  ..#!r6rs.(librar
0140: 79 20 28 73 72 66 69 20 73 36 34 20 74 65 73 74  y (srfi s64 test
0150: 69 6e 67 29 0a 20 20 28 65 78 70 6f 72 74 0a 20  ing).  (export. 
0160: 20 20 20 74 65 73 74 2d 62 65 67 69 6e 0a 20 20     test-begin.  
0170: 20 20 74 65 73 74 2d 65 6e 64 20 74 65 73 74 2d    test-end test-
0180: 61 73 73 65 72 74 20 74 65 73 74 2d 65 71 76 20  assert test-eqv 
0190: 74 65 73 74 2d 65 71 20 74 65 73 74 2d 65 71 75  test-eq test-equ
01a0: 61 6c 0a 20 20 20 20 74 65 73 74 2d 61 70 70 72  al.    test-appr
01b0: 6f 78 69 6d 61 74 65 20 74 65 73 74 2d 65 72 72  oximate test-err
01c0: 6f 72 20 74 65 73 74 2d 61 70 70 6c 79 20 74 65  or test-apply te
01d0: 73 74 2d 77 69 74 68 2d 72 75 6e 6e 65 72 0a 20  st-with-runner. 
01e0: 20 20 20 74 65 73 74 2d 6d 61 74 63 68 2d 6e 74     test-match-nt
01f0: 68 20 74 65 73 74 2d 6d 61 74 63 68 2d 61 6c 6c  h test-match-all
0200: 20 74 65 73 74 2d 6d 61 74 63 68 2d 61 6e 79 20   test-match-any 
0210: 74 65 73 74 2d 6d 61 74 63 68 2d 6e 61 6d 65 0a  test-match-name.
0220: 20 20 20 20 74 65 73 74 2d 73 6b 69 70 20 74 65      test-skip te
0230: 73 74 2d 65 78 70 65 63 74 2d 66 61 69 6c 20 74  st-expect-fail t
0240: 65 73 74 2d 72 65 61 64 2d 65 76 61 6c 2d 73 74  est-read-eval-st
0250: 72 69 6e 67 0a 20 20 20 20 74 65 73 74 2d 67 72  ring.    test-gr
0260: 6f 75 70 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d  oup test-runner-
0270: 67 72 6f 75 70 2d 70 61 74 68 20 74 65 73 74 2d  group-path test-
0280: 67 72 6f 75 70 2d 77 69 74 68 2d 63 6c 65 61 6e  group-with-clean
0290: 75 70 0a 20 20 20 20 74 65 73 74 2d 72 65 73 75  up.    test-resu
02a0: 6c 74 2d 72 65 66 20 74 65 73 74 2d 72 65 73 75  lt-ref test-resu
02b0: 6c 74 2d 73 65 74 21 20 74 65 73 74 2d 72 65 73  lt-set! test-res
02c0: 75 6c 74 2d 63 6c 65 61 72 20 74 65 73 74 2d 72  ult-clear test-r
02d0: 65 73 75 6c 74 2d 72 65 6d 6f 76 65 0a 20 20 20  esult-remove.   
02e0: 20 74 65 73 74 2d 72 65 73 75 6c 74 2d 6b 69 6e   test-result-kin
02f0: 64 20 74 65 73 74 2d 70 61 73 73 65 64 3f 0a 20  d test-passed?. 
0300: 20 20 20 28 72 65 6e 61 6d 65 20 28 25 74 65 73     (rename (%tes
0310: 74 2d 6c 6f 67 2d 74 6f 2d 66 69 6c 65 20 74 65  t-log-to-file te
0320: 73 74 2d 6c 6f 67 2d 74 6f 2d 66 69 6c 65 29 29  st-log-to-file))
0330: 0a 20 20 20 20 3b 20 4d 69 73 63 20 74 65 73 74  .    ; Misc test
0340: 2d 72 75 6e 6e 65 72 20 66 75 6e 63 74 69 6f 6e  -runner function
0350: 73 0a 20 20 20 20 74 65 73 74 2d 72 75 6e 6e 65  s.    test-runne
0360: 72 3f 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d 72  r? test-runner-r
0370: 65 73 65 74 20 74 65 73 74 2d 72 75 6e 6e 65 72  eset test-runner
0380: 2d 6e 75 6c 6c 0a 20 20 20 20 74 65 73 74 2d 72  -null.    test-r
0390: 75 6e 6e 65 72 2d 73 69 6d 70 6c 65 20 74 65 73  unner-simple tes
03a0: 74 2d 72 75 6e 6e 65 72 2d 63 75 72 72 65 6e 74  t-runner-current
03b0: 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d 66 61 63   test-runner-fac
03c0: 74 6f 72 79 20 74 65 73 74 2d 72 75 6e 6e 65 72  tory test-runner
03d0: 2d 67 65 74 0a 20 20 20 20 74 65 73 74 2d 72 75  -get.    test-ru
03e0: 6e 6e 65 72 2d 63 72 65 61 74 65 20 74 65 73 74  nner-create test
03f0: 2d 72 75 6e 6e 65 72 2d 74 65 73 74 2d 6e 61 6d  -runner-test-nam
0400: 65 0a 20 20 20 20 3b 3b 20 74 65 73 74 2d 72 75  e.    ;; test-ru
0410: 6e 6e 65 72 20 66 69 65 6c 64 20 73 65 74 74 65  nner field sette
0420: 72 20 61 6e 64 20 67 65 74 74 65 72 20 66 75 6e  r and getter fun
0430: 63 74 69 6f 6e 73 20 2d 20 73 65 65 20 25 74 65  ctions - see %te
0440: 73 74 2d 72 65 63 6f 72 64 2d 64 65 66 69 6e 65  st-record-define
0450: 3a 0a 20 20 20 20 74 65 73 74 2d 72 75 6e 6e 65  :.    test-runne
0460: 72 2d 70 61 73 73 2d 63 6f 75 6e 74 20 74 65 73  r-pass-count tes
0470: 74 2d 72 75 6e 6e 65 72 2d 70 61 73 73 2d 63 6f  t-runner-pass-co
0480: 75 6e 74 21 0a 20 20 20 20 74 65 73 74 2d 72 75  unt!.    test-ru
0490: 6e 6e 65 72 2d 66 61 69 6c 2d 63 6f 75 6e 74 20  nner-fail-count 
04a0: 74 65 73 74 2d 72 75 6e 6e 65 72 2d 66 61 69 6c  test-runner-fail
04b0: 2d 63 6f 75 6e 74 21 0a 20 20 20 20 74 65 73 74  -count!.    test
04c0: 2d 72 75 6e 6e 65 72 2d 78 70 61 73 73 2d 63 6f  -runner-xpass-co
04d0: 75 6e 74 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d  unt test-runner-
04e0: 78 70 61 73 73 2d 63 6f 75 6e 74 21 0a 20 20 20  xpass-count!.   
04f0: 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d 78 66 61   test-runner-xfa
0500: 69 6c 2d 63 6f 75 6e 74 20 74 65 73 74 2d 72 75  il-count test-ru
0510: 6e 6e 65 72 2d 78 66 61 69 6c 2d 63 6f 75 6e 74  nner-xfail-count
0520: 21 0a 20 20 20 20 74 65 73 74 2d 72 75 6e 6e 65  !.    test-runne
0530: 72 2d 73 6b 69 70 2d 63 6f 75 6e 74 20 74 65 73  r-skip-count tes
0540: 74 2d 72 75 6e 6e 65 72 2d 73 6b 69 70 2d 63 6f  t-runner-skip-co
0550: 75 6e 74 21 0a 20 20 20 20 74 65 73 74 2d 72 75  unt!.    test-ru
0560: 6e 6e 65 72 2d 67 72 6f 75 70 2d 73 74 61 63 6b  nner-group-stack
0570: 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d 67 72 6f   test-runner-gro
0580: 75 70 2d 73 74 61 63 6b 21 0a 20 20 20 20 74 65  up-stack!.    te
0590: 73 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 74 65 73  st-runner-on-tes
05a0: 74 2d 62 65 67 69 6e 20 74 65 73 74 2d 72 75 6e  t-begin test-run
05b0: 6e 65 72 2d 6f 6e 2d 74 65 73 74 2d 62 65 67 69  ner-on-test-begi
05c0: 6e 21 0a 20 20 20 20 74 65 73 74 2d 72 75 6e 6e  n!.    test-runn
05d0: 65 72 2d 6f 6e 2d 74 65 73 74 2d 65 6e 64 20 74  er-on-test-end t
05e0: 65 73 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 74 65  est-runner-on-te
05f0: 73 74 2d 65 6e 64 21 0a 20 20 20 20 74 65 73 74  st-end!.    test
0600: 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 67 72 6f 75 70  -runner-on-group
0610: 2d 62 65 67 69 6e 20 74 65 73 74 2d 72 75 6e 6e  -begin test-runn
0620: 65 72 2d 6f 6e 2d 67 72 6f 75 70 2d 62 65 67 69  er-on-group-begi
0630: 6e 21 0a 20 20 20 20 74 65 73 74 2d 72 75 6e 6e  n!.    test-runn
0640: 65 72 2d 6f 6e 2d 67 72 6f 75 70 2d 65 6e 64 20  er-on-group-end 
0650: 74 65 73 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 67  test-runner-on-g
0660: 72 6f 75 70 2d 65 6e 64 21 0a 20 20 20 20 74 65  roup-end!.    te
0670: 73 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 66 69 6e  st-runner-on-fin
0680: 61 6c 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d 6f  al test-runner-o
0690: 6e 2d 66 69 6e 61 6c 21 0a 20 20 20 20 74 65 73  n-final!.    tes
06a0: 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 62 61 64 2d  t-runner-on-bad-
06b0: 63 6f 75 6e 74 20 74 65 73 74 2d 72 75 6e 6e 65  count test-runne
06c0: 72 2d 6f 6e 2d 62 61 64 2d 63 6f 75 6e 74 21 0a  r-on-bad-count!.
06d0: 20 20 20 20 74 65 73 74 2d 72 75 6e 6e 65 72 2d      test-runner-
06e0: 6f 6e 2d 62 61 64 2d 65 6e 64 2d 6e 61 6d 65 20  on-bad-end-name 
06f0: 74 65 73 74 2d 72 75 6e 6e 65 72 2d 6f 6e 2d 62  test-runner-on-b
0700: 61 64 2d 65 6e 64 2d 6e 61 6d 65 21 0a 20 20 20  ad-end-name!.   
0710: 20 74 65 73 74 2d 72 65 73 75 6c 74 2d 61 6c 69   test-result-ali
0720: 73 74 20 74 65 73 74 2d 72 65 73 75 6c 74 2d 61  st test-result-a
0730: 6c 69 73 74 21 0a 20 20 20 20 74 65 73 74 2d 72  list!.    test-r
0740: 75 6e 6e 65 72 2d 61 75 78 2d 76 61 6c 75 65 20  unner-aux-value 
0750: 74 65 73 74 2d 72 75 6e 6e 65 72 2d 61 75 78 2d  test-runner-aux-
0760: 76 61 6c 75 65 21 0a 20 20 20 20 3b 3b 20 64 65  value!.    ;; de
0770: 66 61 75 6c 74 2f 73 69 6d 70 6c 65 20 63 61 6c  fault/simple cal
0780: 6c 2d 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e 73  l-back functions
0790: 2c 20 75 73 65 64 20 69 6e 20 64 65 66 61 75 6c  , used in defaul
07a0: 74 20 74 65 73 74 2d 72 75 6e 6e 65 72 2c 0a 20  t test-runner,. 
07b0: 20 20 20 3b 3b 20 62 75 74 20 63 61 6e 20 62 65     ;; but can be
07c0: 20 63 61 6c 6c 65 64 20 74 6f 20 63 6f 6e 73 74   called to const
07d0: 72 75 63 74 20 6d 6f 72 65 20 63 6f 6d 70 6c 65  ruct more comple
07e0: 78 20 6f 6e 65 73 2e 0a 20 20 20 20 74 65 73 74  x ones..    test
07f0: 2d 6f 6e 2d 67 72 6f 75 70 2d 62 65 67 69 6e 2d  -on-group-begin-
0800: 73 69 6d 70 6c 65 20 74 65 73 74 2d 6f 6e 2d 67  simple test-on-g
0810: 72 6f 75 70 2d 65 6e 64 2d 73 69 6d 70 6c 65 0a  roup-end-simple.
0820: 20 20 20 20 74 65 73 74 2d 6f 6e 2d 62 61 64 2d      test-on-bad-
0830: 63 6f 75 6e 74 2d 73 69 6d 70 6c 65 20 74 65 73  count-simple tes
0840: 74 2d 6f 6e 2d 62 61 64 2d 65 6e 64 2d 6e 61 6d  t-on-bad-end-nam
0850: 65 2d 73 69 6d 70 6c 65 0a 20 20 20 20 74 65 73  e-simple.    tes
0860: 74 2d 6f 6e 2d 66 69 6e 61 6c 2d 73 69 6d 70 6c  t-on-final-simpl
0870: 65 20 74 65 73 74 2d 6f 6e 2d 74 65 73 74 2d 65  e test-on-test-e
0880: 6e 64 2d 73 69 6d 70 6c 65 29 0a 20 20 28 69 6d  nd-simple).  (im
0890: 70 6f 72 74 0a 20 20 20 20 28 72 6e 72 73 20 62  port.    (rnrs b
08a0: 61 73 65 29 0a 20 20 20 20 28 72 6e 72 73 20 63  ase).    (rnrs c
08b0: 6f 6e 74 72 6f 6c 29 0a 20 20 20 20 28 72 6e 72  ontrol).    (rnr
08c0: 73 20 65 78 63 65 70 74 69 6f 6e 73 29 0a 20 20  s exceptions).  
08d0: 20 20 28 72 6e 72 73 20 69 6f 20 73 69 6d 70 6c    (rnrs io simpl
08e0: 65 29 0a 20 20 20 20 28 72 6e 72 73 20 6c 69 73  e).    (rnrs lis
08f0: 74 73 29 0a 20 20 20 20 28 72 65 6e 61 6d 65 20  ts).    (rename 
0900: 28 72 6e 72 73 20 65 76 61 6c 29 20 28 65 76 61  (rnrs eval) (eva
0910: 6c 20 72 6e 72 73 3a 65 76 61 6c 29 29 0a 20 20  l rnrs:eval)).  
0920: 20 20 28 72 6e 72 73 20 6d 75 74 61 62 6c 65 2d    (rnrs mutable-
0930: 70 61 69 72 73 29 0a 20 20 20 20 28 73 72 66 69  pairs).    (srfi
0940: 20 73 30 20 63 6f 6e 64 2d 65 78 70 61 6e 64 29   s0 cond-expand)
0950: 0a 20 20 20 20 28 6f 6e 6c 79 20 28 73 72 66 69  .    (only (srfi
0960: 20 73 31 20 6c 69 73 74 73 29 20 72 65 76 65 72   s1 lists) rever
0970: 73 65 21 29 0a 20 20 20 20 28 73 72 66 69 20 73  se!).    (srfi s
0980: 36 20 62 61 73 69 63 2d 73 74 72 69 6e 67 2d 70  6 basic-string-p
0990: 6f 72 74 73 29 0a 20 20 20 20 28 73 72 66 69 20  orts).    (srfi 
09a0: 73 39 20 72 65 63 6f 72 64 73 29 0a 20 20 20 20  s9 records).    
09b0: 28 73 72 66 69 20 73 33 39 20 70 61 72 61 6d 65  (srfi s39 parame
09c0: 74 65 72 73 29 0a 20 20 20 20 28 73 72 66 69 20  ters).    (srfi 
09d0: 73 32 33 20 65 72 72 6f 72 20 74 72 69 63 6b 73  s23 error tricks
09e0: 29 0a 20 20 20 20 28 73 72 66 69 20 70 72 69 76  ).    (srfi priv
09f0: 61 74 65 20 69 6e 63 6c 75 64 65 29 29 0a 0a 20  ate include)).. 
0a00: 20 28 64 65 66 69 6e 65 20 28 65 76 61 6c 20 66   (define (eval f
0a10: 6f 72 6d 29 0a 20 20 20 20 28 72 6e 72 73 3a 65  orm).    (rnrs:e
0a20: 76 61 6c 20 66 6f 72 6d 20 28 65 6e 76 69 72 6f  val form (enviro
0a30: 6e 6d 65 6e 74 20 27 28 72 6e 72 73 29 0a 20 20  nment '(rnrs).  
0a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0a50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 27                 '
0a60: 28 72 6e 72 73 20 65 76 61 6c 29 0a 20 20 20 20  (rnrs eval).    
0a70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 27 28 72               '(r
0a90: 6e 72 73 20 6d 75 74 61 62 6c 65 2d 70 61 69 72  nrs mutable-pair
0aa0: 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  s).             
0ab0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0ac0: 20 20 20 20 27 28 72 6e 72 73 20 6d 75 74 61 62      '(rnrs mutab
0ad0: 6c 65 2d 73 74 72 69 6e 67 73 29 0a 20 20 20 20  le-strings).    
0ae0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0af0: 20 20 20 20 20 20 20 20 20 20 20 20 20 27 28 72               '(r
0b00: 6e 72 73 20 72 35 72 73 29 29 29 29 0a 0a 20 20  nrs r5rs))))..  
0b10: 28 64 65 66 69 6e 65 20 25 74 65 73 74 2d 6c 6f  (define %test-lo
0b20: 67 2d 74 6f 2d 66 69 6c 65 0a 20 20 20 20 28 63  g-to-file.    (c
0b30: 61 73 65 2d 6c 61 6d 62 64 61 0a 20 20 20 20 20  ase-lambda.     
0b40: 20 28 28 29 20 74 65 73 74 2d 6c 6f 67 2d 74 6f   (() test-log-to
0b50: 2d 66 69 6c 65 29 0a 20 20 20 20 20 20 28 28 76  -file).      ((v
0b60: 61 6c 29 20 28 73 65 74 21 20 74 65 73 74 2d 6c  al) (set! test-l
0b70: 6f 67 2d 74 6f 2d 66 69 6c 65 20 76 61 6c 29 29  og-to-file val))
0b80: 29 29 0a 20 20 0a 20 20 28 53 52 46 49 2d 32 33  )).  .  (SRFI-23
0b90: 2d 65 72 72 6f 72 2d 3e 52 36 52 53 20 22 28 6c  -error->R6RS "(l
0ba0: 69 62 72 61 72 79 20 28 73 72 66 69 20 73 36 34  ibrary (srfi s64
0bb0: 20 74 65 73 74 69 6e 67 29 29 22 0a 20 20 20 28   testing))".   (
0bc0: 69 6e 63 6c 75 64 65 2f 72 65 73 6f 6c 76 65 20  include/resolve 
0bd0: 28 22 73 72 66 69 22 20 22 73 36 34 22 29 20 22  ("srfi" "s64") "
0be0: 74 65 73 74 69 6e 67 2e 73 63 6d 22 29 29 0a 29  testing.scm")).)
0bf0: 0a                                               .