From 73a4bfc3d8e9bb5365e33a11a6ad3b8340d5195b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 12 Jun 2022 21:09:35 +0200 Subject: Remove custom let*. While it was nice, the most important part was the multi-valued let from srfi-71 (which is implemented in srfi-71)). The minor pattern matching structures could often be replaced with car+cdr, or a propper match. --- tests/test/datetime.scm | 20 ++++++++-------- tests/test/let.scm | 45 ------------------------------------ tests/test/server.scm | 8 +++---- tests/test/web-server.scm | 58 +++++++++++++++++++++++------------------------ 4 files changed, 43 insertions(+), 88 deletions(-) delete mode 100644 tests/test/let.scm (limited to 'tests') diff --git a/tests/test/datetime.scm b/tests/test/datetime.scm index 3435aad6..d646052d 100644 --- a/tests/test/datetime.scm +++ b/tests/test/datetime.scm @@ -5,12 +5,12 @@ (define-module (test datetime) :use-module (srfi srfi-64) + :use-module (srfi srfi-71) :use-module (srfi srfi-88) :use-module ((srfi srfi-41) :select (stream->list stream-take)) :use-module (datetime) :use-module ((ice-9 format) :select (format)) - :use-module ((hnh util) :select (let*)) :use-module ((ice-9 i18n) :select (make-locale)) :use-module ((guile) :select (LC_CTYPE LC_TIME))) @@ -164,18 +164,18 @@ (date day: 4) (date day: 5))) -(let* ((diff overflow - (time- #10:20:30 - #10:20:30))) +(let ((diff overflow + (time- #10:20:30 + #10:20:30))) (test-equal "time- self" #00:00:00 diff) (test-equal "time- self overflow" 0 overflow)) -(let* ((diff overflow - (time- #10:00:00 - #10:00:01))) +(let ((diff overflow + (time- #10:00:00 + #10:00:01))) (test-equal "time- overflow 1s" #23:59:59 @@ -185,9 +185,9 @@ 1 overflow)) -(let* ((diff overflow - (time- #10:00:00 - (time hour: (+ 48 4))))) +(let ((diff overflow + (time- #10:00:00 + (time hour: (+ 48 4))))) (test-equal "time- overflow multiple" #06:00:00 diff --git a/tests/test/let.scm b/tests/test/let.scm deleted file mode 100644 index 5312409e..00000000 --- a/tests/test/let.scm +++ /dev/null @@ -1,45 +0,0 @@ -;;; Commentary: -;; Tests my custom let*. -;;; Code: - -(define-module (test let) - :use-module (srfi srfi-64) - :use-module (srfi srfi-88) - :use-module ((hnh util) :select (let*))) - -(test-assert (let* ((a #t)) a)) - -(test-assert (let* (((a . b) (cons #t #f))) a)) - -(test-assert (let* (((a . b) (cons* #f #t))) b)) - -(test-assert - (let* ((a b c (values #f #t #f))) b)) - -(test-assert - (let* (((a b c) (list #f #t #f))) b)) - -(test-assert (let* (((a) '(#t))) a)) - -(test-equal '(2) (let* (((a . b) '(1 2))) b)) - -(test-equal - '(3 4) - (let* (((a b . c) '(1 2 3 4))) c)) - -(test-equal 10 (let* (x) (set! x 10) x)) - -(test-equal - 30 - (let* (x y) (set! x 10) (set! y 20) (+ x y))) - -(test-assert (let* (x) (not x))) - -(test-equal - 6 - (let* ((x 1) y z) - (set! y 2) - (set! z 3) - (+ x y z))) - - diff --git a/tests/test/server.scm b/tests/test/server.scm index 1b5d4775..43b60769 100644 --- a/tests/test/server.scm +++ b/tests/test/server.scm @@ -4,21 +4,21 @@ (define-module (test server) :use-module (srfi srfi-64) + :use-module (srfi srfi-71) :use-module (srfi srfi-88) :use-module ((web http make-routes) - :select (parse-endpoint-string)) - :use-module ((hnh util) :select (let*))) + :select (parse-endpoint-string))) (test-assert "Check that parsing doesn't crash" (parse-endpoint-string "/static/:dir/:file")) ;; Checks that parsing produces correct results -(let* ((path args (parse-endpoint-string "/static/:dir/:file"))) +(let ((path args (parse-endpoint-string "/static/:dir/:file"))) (test-equal "/static/([^/.]+)/([^/.]+)" path) (test-equal '(dir file) args)) ;; Checks that parsing with custom regex works ;; along with literal periods. -(let* ((path args (parse-endpoint-string "/static/:filename{.*}.:ext"))) +(let ((path args (parse-endpoint-string "/static/:filename{.*}.:ext"))) (test-equal "/static/(.*)\\.([^/.]+)" path) (test-equal '(filename ext) args)) diff --git a/tests/test/web-server.scm b/tests/test/web-server.scm index e5a796b6..69d18536 100644 --- a/tests/test/web-server.scm +++ b/tests/test/web-server.scm @@ -9,13 +9,13 @@ (define-module (test web-server) :use-module (srfi srfi-64) + :use-module (srfi srfi-71) :use-module (srfi srfi-88) :use-module ((calp server routes) :select (make-make-routes)) :use-module ((web server) :select (run-server)) :use-module ((ice-9 threads) :select (call-with-new-thread cancel-thread)) :use-module ((web client) :select (http-get)) - :use-module ((hnh util) :select (let*)) :use-module ((web response) :select (response-code response-location)) :use-module ((web uri) :select (build-uri uri-path)) :use-module ((guile) @@ -71,39 +71,39 @@ ;; This test should always fail, but should never be run (test-assert "Server returned unexpectedly" #f)))) -(let* ((response - _ - (catch 'system-error - (lambda () - (http-get - (build-uri 'http host: host port: port))) - (lambda (err proc fmt args data) - (format - (current-error-port) - "~a (in ~a) ~?~%" - err - proc - fmt - args) - (values (build-response code: 500) #f))))) +(let ((response + _ + (catch 'system-error + (lambda () + (http-get + (build-uri 'http host: host port: port))) + (lambda (err proc fmt args data) + (format + (current-error-port) + "~a (in ~a) ~?~%" + err + proc + fmt + args) + (values (build-response code: 500) #f))))) (test-eqv "Basic connect" 200 (response-code response))) -(let* ((response - body - (http-get - (build-uri - 'http - host: - host - port: - port - path: - "/today" - query: - "view=week&date=2020-01-04")))) +(let ((response + body + (http-get + (build-uri + 'http + host: + host + port: + port + path: + "/today" + query: + "view=week&date=2020-01-04")))) (test-eqv "Redirect" 302 -- cgit v1.2.3