From 91133c2d71960644eeba749027a4141c098ea64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 16 Oct 2012 23:01:01 +0200 Subject: utils: Add `fold-port-matches' and `remove-store-references'. * guix/build/utils.scm (fold-port-matches, remove-store-references): New procedures. * tests/build-utils.scm ("fold-port-matches", "fold-port-matches, trickier", "fold-port-matches, with unmatched chars"): New tests. --- tests/build-utils.scm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/build-utils.scm b/tests/build-utils.scm index 4d86037708..8140708397 100644 --- a/tests/build-utils.scm +++ b/tests/build-utils.scm @@ -47,6 +47,39 @@ (not (false-if-exception (alist-replace 'z 77 '((a . 1) (b . 2) (c . 3)))))) +(test-equal "fold-port-matches" + (make-list 3 "Guix") + (call-with-input-string "Guix is cool, Guix rocks, and it uses Guile, Guix!" + (lambda (port) + (fold-port-matches cons '() "Guix" port)))) + +(test-equal "fold-port-matches, trickier" + (reverse '("Guix" "guix" "Guix" "guiX" "Guix")) + (call-with-input-string "Guix, guix, GuiGuixguiX, Guix" + (lambda (port) + (fold-port-matches cons '() + (list (char-set #\G #\g) + (char-set #\u) + (char-set #\i) + (char-set #\x #\X)) + port)))) + +(test-equal "fold-port-matches, with unmatched chars" + '("Guix" #\, #\space + "guix" #\, #\space + #\G #\u #\i "Guix" "guiX" #\, #\space + "Guix") + (call-with-input-string "Guix, guix, GuiGuixguiX, Guix" + (lambda (port) + (reverse + (fold-port-matches cons '() + (list (char-set #\G #\g) + (char-set #\u) + (char-set #\i) + (char-set #\x #\X)) + port + cons))))) + (test-end) @@ -55,4 +88,5 @@ ;;; Local Variables: ;;; eval: (put 'test-assert 'scheme-indent-function 1) ;;; eval: (put 'test-equal 'scheme-indent-function 1) +;;; eval: (put 'call-with-input-string 'scheme-indent-function 1) ;;; End: -- cgit v1.2.3