diff options
author | Paul A. Patience <paul@apatience.com> | 2021-07-04 23:38:07 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-05 14:35:49 -0700 |
commit | c656cf912e32f394a525d970bce7b08e47f06333 (patch) | |
tree | 28e2a10ea4a44cb3500e7ad5a8fb0df4a6c67e57 /tests | |
parent | b632bc645ba4fc72e1434cf58327b653bbf73c5b (diff) | |
download | txr-c656cf912e32f394a525d970bce7b08e47f06333.tar.gz txr-c656cf912e32f394a525d970bce7b08e47f06333.tar.bz2 txr-c656cf912e32f394a525d970bce7b08e47f06333.zip |
genman, lib, tests: use defvarl where possible.
* genman.txr (dupes, tagnum): Replace defvar with defvarl.
* stdlib/doc-lookup.tl (os-symbol): Same.
* tests/011/macros-3.tl (x): Same.
* tests/011/mandel.txr (x-centre, y-centre, width, i-max, j-max, n)
(r-max, pixel-size, x-offset, y-offset): Same.
(file, colour-max): Delete (unused) variables.
* tests/012/circ.tl (x): Replace defvar with defvarl.
* tests/012/stack.tl (stack-limited): Same.
* tests/012/struct.tl (s): Same.
* tests/013/maze.tl (vi, pa, sc): Delete variables. Use
function arguments instead.
(usage): Fix typo.
* tests/014/dgram-stream.tl (family): Rename to...
(*family*): ...this.
* tests/014/socket-basic.tl (socktype): Rename to...
(*socktype*): ...this.
(%iters%): Replace defvar with defvarl.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/011/macros-3.tl | 2 | ||||
-rw-r--r-- | tests/011/mandel.txr | 22 | ||||
-rw-r--r-- | tests/012/circ.tl | 6 | ||||
-rw-r--r-- | tests/012/stack.tl | 2 | ||||
-rw-r--r-- | tests/012/struct.tl | 2 | ||||
-rw-r--r-- | tests/013/maze.tl | 16 | ||||
-rw-r--r-- | tests/014/dgram-stream.tl | 8 | ||||
-rw-r--r-- | tests/014/socket-basic.tl | 10 |
8 files changed, 31 insertions, 37 deletions
diff --git a/tests/011/macros-3.tl b/tests/011/macros-3.tl index e08e5da7..9a595021 100644 --- a/tests/011/macros-3.tl +++ b/tests/011/macros-3.tl @@ -11,7 +11,7 @@ (m)))))) 42) -(defvar x 0) +(defvarl x 0) (defmacro mac-time-counter () (inc x)) (defsymacro s (mac-time-counter)) diff --git a/tests/011/mandel.txr b/tests/011/mandel.txr index 8a701526..cfa24857 100644 --- a/tests/011/mandel.txr +++ b/tests/011/mandel.txr @@ -1,16 +1,14 @@ @(do - (defvar x-centre -0.5) - (defvar y-centre 0.0) - (defvar width 4.0) - (defvar i-max 80) - (defvar j-max 60) - (defvar n 100) - (defvar r-max 2.0) - (defvar file "mandelbrot.pgm") - (defvar colour-max 255) - (defvar pixel-size (/ width i-max)) - (defvar x-offset (- x-centre (* 0.5 pixel-size (+ i-max 1)))) - (defvar y-offset (+ y-centre (* 0.5 pixel-size (+ j-max 1)))) + (defvarl x-centre -0.5) + (defvarl y-centre 0.0) + (defvarl width 4.0) + (defvarl i-max 80) + (defvarl j-max 60) + (defvarl n 100) + (defvarl r-max 2.0) + (defvarl pixel-size (/ width i-max)) + (defvarl x-offset (- x-centre (* 0.5 pixel-size (+ i-max 1)))) + (defvarl y-offset (+ y-centre (* 0.5 pixel-size (+ j-max 1)))) ;; complex number library (macro-time diff --git a/tests/012/circ.tl b/tests/012/circ.tl index 4b6e9990..82abe745 100644 --- a/tests/012/circ.tl +++ b/tests/012/circ.tl @@ -5,9 +5,9 @@ (print me.a stream pretty-p) (put-string "]]" stream))) -(defvar x (let* ((l (list "a")) - (c (new circ-print a l))) - (list l c))) +(defvarl x (let* ((l (list "a")) + (c (new circ-print a l))) + (list l c))) (let ((*print-circle* t)) (prinl (new circ-print a "a")) diff --git a/tests/012/stack.tl b/tests/012/stack.tl index 9a7534bb..62df252b 100644 --- a/tests/012/stack.tl +++ b/tests/012/stack.tl @@ -1,6 +1,6 @@ (load "../common") -(defvar stack-limited (set-stack-limit 32768)) +(defvarl stack-limited (set-stack-limit 32768)) (defun recur () (recur)) diff --git a/tests/012/struct.tl b/tests/012/struct.tl index 3f03552d..bdff6311 100644 --- a/tests/012/struct.tl +++ b/tests/012/struct.tl @@ -16,7 +16,7 @@ (test (expand '^#S(bar b ,(+ 2 2))) (sys:make-struct-lit 'bar (list 'b (+ 2 2)))) -(defvar s (eval ^#S(bar b ,(+ 2 2)))) +(defvarl s (eval ^#S(bar b ,(+ 2 2)))) (test (set (slot s 'a) 100) 100) diff --git a/tests/013/maze.tl b/tests/013/maze.tl index 5cb989d6..38dca3e3 100644 --- a/tests/013/maze.tl +++ b/tests/013/maze.tl @@ -1,7 +1,3 @@ -(defvar vi) ;; visited hash -(defvar pa) ;; path connectivity hash -(defvar sc) ;; count, derived from straightness fator - (defun scramble (list) (let ((out ())) (each ((item list)) @@ -18,7 +14,7 @@ (list (- x 1)..y (+ x 1)..y x..(- y 1) x..(+ y 1)))) -(defun make-maze-impl (cu) +(defun make-maze-impl (vi pa sc cu) (let ((fr (hash :equal-based)) (q (list cu)) (c sc)) @@ -38,16 +34,16 @@ (pop q))))))) (defun make-maze (w h sf) - (let ((vi (hash :equal-based)) - (pa (hash :equal-based)) - (sc (max 1 (int-flo (trunc (* sf w h) 100.0))))) + (let ((vi (hash :equal-based)) ;; visited hash + (pa (hash :equal-based)) ;; path connectivity hash + (sc (max 1 (int-flo (trunc (* sf w h) 100.0))))) ;; go straight count (each ((x (range -1 w))) (set [vi x..-1] t) (set [vi x..h] t)) (each ((y (range* 0 h))) (set [vi -1..y] t) (set [vi w..y] t)) - (make-maze-impl 0..0) + (make-maze-impl vi pa sc 0..0) ;; Open start and end (push 0..-1 [pa 0..0]) (push (- w 1)..(- h 1) [pa (- w 1)..h]) @@ -78,7 +74,7 @@ (let ((invocation (ldiff *full-args* *args*))) (put-line "usage: ") (put-line `@invocation <width> <height> [<straightness>]`) - (put-line "straightness-factor is a percentage, defaulting to 15") + (put-line "straightness is a percentage, defaulting to 15") (exit 1))) (let ((args [mapcar num-str *args*])) diff --git a/tests/014/dgram-stream.tl b/tests/014/dgram-stream.tl index 5902a84d..6890e300 100644 --- a/tests/014/dgram-stream.tl +++ b/tests/014/dgram-stream.tl @@ -1,7 +1,7 @@ (load "../common.tl") (load "../sock-common.tl") -(defvar family) +(defvar *family*) (defun server (svc-sock) (whilet ((acc-sock (sock-accept svc-sock)) @@ -10,7 +10,7 @@ (close-stream acc-sock))) (defun client (addr) - (with-stream (cli-sock (open-socket family sock-dgram)) + (with-stream (cli-sock (open-socket *family* sock-dgram)) (sock-connect cli-sock addr) (dotimes (i 1000) (print i cli-sock) @@ -22,7 +22,7 @@ (flush-stream cli-sock))) (defun dgram-test () - (let* ((svc-sock (open-socket family sock-dgram)) + (let* ((svc-sock (open-socket *family* sock-dgram)) (svc-addr (bindfree svc-sock 1025 65535)) (server-pid (fork))) (cond @@ -37,6 +37,6 @@ (fboundp 'fork)) (let ((maybe-ipv6 (if (memq (os-symbol) '(:linux :macos :cygwin :cygnal)) (list af-inet6)))) - (each ((family ^(,af-inet ,*maybe-ipv6))) + (each ((*family* ^(,af-inet ,*maybe-ipv6))) (unless (dgram-test) (error "test failed"))))) diff --git a/tests/014/socket-basic.tl b/tests/014/socket-basic.tl index 1b4464fb..ae591c9b 100644 --- a/tests/014/socket-basic.tl +++ b/tests/014/socket-basic.tl @@ -1,12 +1,12 @@ (load "../sock-common.tl") (load "../common.tl") -(defvar socktype) +(defvar *socktype*) -(defvar %iters% (if (meql (os-symbol) :macos :openbsd) 2000 5000)) +(defvarl %iters% (if (meql (os-symbol) :macos :openbsd) 2000 5000)) (defun client (addr) - (with-stream (cli-sock (open-socket af-inet socktype)) + (with-stream (cli-sock (open-socket af-inet *socktype*)) (sock-connect cli-sock addr) (put-string "5000" cli-sock) (sock-shutdown cli-sock) @@ -19,7 +19,7 @@ (close-stream acc-sock))) (defun sock-test () - (let* ((svc-sock (open-socket af-inet socktype)) + (let* ((svc-sock (open-socket af-inet *socktype*)) (svc-addr (bindfree svc-sock 1025 65535)) (child-pid (fork))) (cond @@ -29,6 +29,6 @@ (if (and (fboundp 'open-socket) (fboundp 'fork)) - (each ((socktype (list sock-dgram sock-stream))) + (each ((*socktype* (list sock-dgram sock-stream))) (unless (sock-test) (error "test failed")))) |