Artifact
a8abe5abb0da086e9e09815b17909ab5dd316dec:
0000: 3b 3b 20 20 43 6f 70 79 72 69 67 68 74 20 32 30 ;; Copyright 20
0010: 30 36 2d 32 30 31 37 2c 20 4d 61 74 74 68 65 77 06-2017, Matthew
0020: 20 57 65 6c 6c 61 6e 64 2e 0a 3b 3b 20 0a 3b 3b Welland..;; .;;
0030: 20 54 68 69 73 20 66 69 6c 65 20 69 73 20 70 61 This file is pa
0040: 72 74 20 6f 66 20 4d 65 67 61 74 65 73 74 2e 0a rt of Megatest..
0050: 3b 3b 20 0a 3b 3b 20 20 20 20 20 4d 65 67 61 74 ;; .;; Megat
0060: 65 73 74 20 69 73 20 66 72 65 65 20 73 6f 66 74 est is free soft
0070: 77 61 72 65 3a 20 79 6f 75 20 63 61 6e 20 72 65 ware: you can re
0080: 64 69 73 74 72 69 62 75 74 65 20 69 74 20 61 6e distribute it an
0090: 64 2f 6f 72 20 6d 6f 64 69 66 79 0a 3b 3b 20 20 d/or modify.;;
00a0: 20 20 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 it under the
00b0: 74 65 72 6d 73 20 6f 66 20 74 68 65 20 47 4e 55 terms of the GNU
00c0: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 General Public
00d0: 4c 69 63 65 6e 73 65 20 61 73 20 70 75 62 6c 69 License as publi
00e0: 73 68 65 64 20 62 79 0a 3b 3b 20 20 20 20 20 74 shed by.;; t
00f0: 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 72 65 he Free Software
0100: 20 46 6f 75 6e 64 61 74 69 6f 6e 2c 20 65 69 74 Foundation, eit
0110: 68 65 72 20 76 65 72 73 69 6f 6e 20 33 20 6f 66 her version 3 of
0120: 20 74 68 65 20 4c 69 63 65 6e 73 65 2c 20 6f 72 the License, or
0130: 0a 3b 3b 20 20 20 20 20 28 61 74 20 79 6f 75 72 .;; (at your
0140: 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 option) any lat
0150: 65 72 20 76 65 72 73 69 6f 6e 2e 0a 3b 3b 20 0a er version..;; .
0160: 3b 3b 20 20 20 20 20 4d 65 67 61 74 65 73 74 20 ;; Megatest
0170: 69 73 20 64 69 73 74 72 69 62 75 74 65 64 20 69 is distributed i
0180: 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 74 20 n the hope that
0190: 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66 75 it will be usefu
01a0: 6c 2c 0a 3b 3b 20 20 20 20 20 62 75 74 20 57 49 l,.;; but WI
01b0: 54 48 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e THOUT ANY WARRAN
01c0: 54 59 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e TY; without even
01d0: 20 74 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 the implied war
01e0: 72 61 6e 74 79 20 6f 66 0a 3b 3b 20 20 20 20 20 ranty of.;;
01f0: 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 59 20 MERCHANTABILITY
0200: 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 or FITNESS FOR A
0210: 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 PARTICULAR PURP
0220: 4f 53 45 2e 20 20 53 65 65 20 74 68 65 0a 3b 3b OSE. See the.;;
0230: 20 20 20 20 20 47 4e 55 20 47 65 6e 65 72 61 6c GNU General
0240: 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 Public License
0250: 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 for more details
0260: 2e 0a 3b 3b 20 0a 3b 3b 20 20 20 20 20 59 6f 75 ..;; .;; You
0270: 20 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 should have rec
0280: 65 69 76 65 64 20 61 20 63 6f 70 79 20 6f 66 20 eived a copy of
0290: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
02a0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 0a 3b Public License.;
02b0: 3b 20 20 20 20 20 61 6c 6f 6e 67 20 77 69 74 68 ; along with
02c0: 20 4d 65 67 61 74 65 73 74 2e 20 20 49 66 20 6e Megatest. If n
02d0: 6f 74 2c 20 73 65 65 20 3c 68 74 74 70 3a 2f 2f ot, see <http://
02e0: 77 77 77 2e 67 6e 75 2e 6f 72 67 2f 6c 69 63 65 www.gnu.org/lice
02f0: 6e 73 65 73 2f 3e 2e 0a 3b 3b 0a 28 69 6d 70 6f nses/>..;;.(impo
0300: 72 74 20 73 72 66 69 2d 36 39 29 0a 0a 28 64 65 rt srfi-69)..(de
0310: 66 69 6e 65 20 28 72 75 6e 73 3a 71 75 65 75 65 fine (runs:queue
0320: 2d 6e 65 78 74 2d 68 65 64 20 74 61 6c 20 72 65 -next-hed tal re
0330: 67 20 6e 20 72 65 67 66 75 6c 29 0a 20 20 28 69 g n regful). (i
0340: 66 20 72 65 67 66 75 6c 0a 20 20 20 20 20 20 28 f regful. (
0350: 63 61 72 20 72 65 67 29 0a 20 20 20 20 20 20 28 car reg). (
0360: 63 61 72 20 74 61 6c 29 29 29 0a 0a 28 64 65 66 car tal)))..(def
0370: 69 6e 65 20 28 72 75 6e 73 3a 71 75 65 75 65 2d ine (runs:queue-
0380: 6e 65 78 74 2d 74 61 6c 20 74 61 6c 20 72 65 67 next-tal tal reg
0390: 20 6e 20 72 65 67 66 75 6c 29 0a 20 20 28 69 66 n regful). (if
03a0: 20 72 65 67 66 75 6c 0a 20 20 20 20 20 20 74 61 regful. ta
03b0: 6c 0a 20 20 20 20 20 20 28 6c 65 74 20 28 28 6e l. (let ((n
03c0: 65 77 74 61 6c 20 28 63 64 72 20 74 61 6c 29 29 ewtal (cdr tal))
03d0: 29 0a 09 28 69 66 20 28 6e 75 6c 6c 3f 20 6e 65 )..(if (null? ne
03e0: 77 74 61 6c 29 0a 09 20 20 20 20 72 65 67 0a 09 wtal).. reg..
03f0: 20 20 20 20 6e 65 77 74 61 6c 0a 09 20 20 20 20 newtal..
0400: 29 29 29 29 0a 0a 28 64 65 66 69 6e 65 20 28 72 ))))..(define (r
0410: 75 6e 73 3a 71 75 65 75 65 2d 6e 65 78 74 2d 72 uns:queue-next-r
0420: 65 67 20 74 61 6c 20 72 65 67 20 6e 20 72 65 67 eg tal reg n reg
0430: 66 75 6c 29 0a 20 20 28 69 66 20 72 65 67 66 75 ful). (if regfu
0440: 6c 0a 20 20 20 20 20 20 28 63 64 72 20 72 65 67 l. (cdr reg
0450: 29 0a 20 20 20 20 20 20 28 69 66 20 28 65 71 3f ). (if (eq?
0460: 20 28 6c 65 6e 67 74 68 20 74 61 6c 29 20 31 29 (length tal) 1)
0470: 0a 09 20 20 27 28 29 0a 09 20 20 72 65 67 29 29 .. '().. reg))
0480: 29 0a 0a 28 69 6d 70 6f 72 74 20 74 72 61 63 65 )..(import trace
0490: 29 0a 28 74 72 61 63 65 20 72 75 6e 73 3a 71 75 ).(trace runs:qu
04a0: 65 75 65 2d 6e 65 78 74 2d 68 65 64 0a 20 20 20 eue-next-hed.
04b0: 20 20 20 20 72 75 6e 73 3a 71 75 65 75 65 2d 6e runs:queue-n
04c0: 65 78 74 2d 74 61 6c 0a 20 20 20 20 20 20 20 72 ext-tal. r
04d0: 75 6e 73 3a 71 75 65 75 65 2d 6e 65 78 74 2d 72 uns:queue-next-r
04e0: 65 67 29 0a 0a 0a 28 64 65 66 69 6e 65 20 74 65 eg)...(define te
04f0: 73 74 73 20 27 28 31 20 32 20 33 20 34 20 35 20 sts '(1 2 3 4 5
0500: 36 20 37 20 38 20 39 20 31 30 20 31 31 20 31 32 6 7 8 9 10 11 12
0510: 20 31 33 20 31 34 20 31 35 20 31 36 20 31 37 20 13 14 15 16 17
0520: 31 38 20 31 39 20 32 30 29 29 0a 0a 28 64 65 66 18 19 20))..(def
0530: 69 6e 65 20 74 65 73 74 2d 72 65 67 69 73 74 72 ine test-registr
0540: 79 20 28 6d 61 6b 65 2d 68 61 73 68 2d 74 61 62 y (make-hash-tab
0550: 6c 65 29 29 0a 0a 28 64 65 66 69 6e 65 20 6e 20 le))..(define n
0560: 33 29 0a 0a 28 6c 65 74 20 6c 6f 6f 70 20 28 28 3)..(let loop ((
0570: 68 65 64 20 20 20 28 63 61 72 20 74 65 73 74 73 hed (car tests
0580: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 28 74 )). (t
0590: 61 6c 20 20 20 28 63 64 72 20 74 65 73 74 73 29 al (cdr tests)
05a0: 29 0a 20 20 20 20 20 20 20 20 20 20 20 28 72 65 ). (re
05b0: 67 20 20 20 27 28 29 29 29 0a 20 20 28 6c 65 74 g '())). (let
05c0: 2a 20 28 28 72 65 67 6c 65 6e 20 28 6c 65 6e 67 * ((reglen (leng
05d0: 74 68 20 72 65 67 29 29 0a 09 20 28 72 65 67 66 th reg)).. (regf
05e0: 75 6c 20 28 3e 20 72 65 67 6c 65 6e 20 6e 29 29 ul (> reglen n))
05f0: 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22 68 65 ). (print "he
0600: 64 3d 22 20 68 65 64 20 22 2c 20 6c 65 6e 67 74 d=" hed ", lengt
0610: 68 20 72 65 67 3d 22 20 28 6c 65 6e 67 74 68 20 h reg=" (length
0620: 72 65 67 29 20 22 2c 20 28 3e 20 6c 65 6e 72 65 reg) ", (> lenre
0630: 67 20 6e 29 3d 22 20 28 3e 20 28 6c 65 6e 67 74 g n)=" (> (lengt
0640: 68 20 72 65 67 29 20 6e 29 29 0a 20 20 20 20 28 h reg) n)). (
0650: 6c 65 74 20 28 28 6e 65 77 74 61 6c 20 28 61 70 let ((newtal (ap
0660: 70 65 6e 64 20 74 61 6c 20 28 6c 69 73 74 20 68 pend tal (list h
0670: 65 64 29 29 29 29 20 3b 3b 20 75 73 65 64 20 69 ed)))) ;; used i
0680: 66 20 77 65 20 61 72 65 20 6e 6f 74 20 64 6f 6e f we are not don
0690: 65 20 77 69 74 68 20 74 68 69 73 20 74 65 73 74 e with this test
06a0: 0a 20 20 20 20 20 20 28 63 6f 6e 64 0a 20 20 20 . (cond.
06b0: 20 20 20 20 28 28 6e 6f 74 20 28 68 61 73 68 2d ((not (hash-
06c0: 74 61 62 6c 65 2d 72 65 66 2f 64 65 66 61 75 6c table-ref/defaul
06d0: 74 20 74 65 73 74 2d 72 65 67 69 73 74 72 79 20 t test-registry
06e0: 68 65 64 20 23 66 29 29 0a 09 28 68 61 73 68 2d hed #f))..(hash-
06f0: 74 61 62 6c 65 2d 73 65 74 21 20 74 65 73 74 2d table-set! test-
0700: 72 65 67 69 73 74 72 79 20 68 65 64 20 23 74 29 registry hed #t)
0710: 0a 09 28 70 72 69 6e 74 20 22 52 65 67 69 73 74 ..(print "Regist
0720: 65 72 69 6e 67 20 23 22 20 68 65 64 29 0a 09 28 ering #" hed)..(
0730: 69 66 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 74 if (not (null? t
0740: 61 6c 29 29 0a 20 20 20 20 20 20 20 20 20 20 28 al)). (
0750: 6c 6f 6f 70 20 28 72 75 6e 73 3a 71 75 65 75 65 loop (runs:queue
0760: 2d 6e 65 78 74 2d 68 65 64 20 74 61 6c 20 72 65 -next-hed tal re
0770: 67 20 6e 20 72 65 67 66 75 6c 29 0a 20 20 20 20 g n regful).
0780: 20 20 20 20 20 20 20 20 20 20 20 20 28 72 75 6e (run
0790: 73 3a 71 75 65 75 65 2d 6e 65 78 74 2d 74 61 6c s:queue-next-tal
07a0: 20 74 61 6c 20 72 65 67 20 6e 20 72 65 67 66 75 tal reg n regfu
07b0: 6c 29 0a 09 09 28 6c 65 74 20 28 28 6e 65 77 6c l)...(let ((newl
07c0: 20 28 61 70 70 65 6e 64 20 72 65 67 20 28 6c 69 (append reg (li
07d0: 73 74 20 68 65 64 29 29 29 29 0a 09 09 20 20 28 st hed))))... (
07e0: 69 66 20 72 65 67 66 75 6c 0a 09 09 20 20 20 20 if regful...
07f0: 20 20 28 63 64 72 20 6e 65 77 6c 29 0a 09 09 20 (cdr newl)...
0800: 20 20 20 20 20 6e 65 77 6c 29 29 29 29 29 0a 20 newl))))).
0810: 20 20 20 20 20 20 28 65 6c 73 65 0a 09 28 70 72 (else..(pr
0820: 69 6e 74 20 22 52 75 6e 6e 69 6e 67 20 23 22 20 int "Running #"
0830: 68 65 64 29 0a 09 28 69 66 20 28 6e 6f 74 20 28 hed)..(if (not (
0840: 6e 75 6c 6c 3f 20 74 61 6c 29 29 0a 09 20 20 20 null? tal))..
0850: 20 28 6c 6f 6f 70 20 28 72 75 6e 73 3a 71 75 65 (loop (runs:que
0860: 75 65 2d 6e 65 78 74 2d 68 65 64 20 74 61 6c 20 ue-next-hed tal
0870: 72 65 67 20 6e 20 72 65 67 66 75 6c 29 0a 09 09 reg n regful)...
0880: 20 20 28 72 75 6e 73 3a 71 75 65 75 65 2d 6e 65 (runs:queue-ne
0890: 78 74 2d 74 61 6c 20 74 61 6c 20 72 65 67 20 6e xt-tal tal reg n
08a0: 20 72 65 67 66 75 6c 29 0a 09 09 20 20 28 72 75 regful)... (ru
08b0: 6e 73 3a 71 75 65 75 65 2d 6e 65 78 74 2d 72 65 ns:queue-next-re
08c0: 67 20 74 61 6c 20 72 65 67 20 6e 20 72 65 67 66 g tal reg n regf
08d0: 75 6c 29 29 29 29 29 29 29 29 0a ul)))))))).