summaryrefslogtreecommitdiff
path: root/tests/build-utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-10-16 23:01:01 +0200
committerLudovic Courtès <ludo@gnu.org>2012-10-16 23:01:01 +0200
commit91133c2d71960644eeba749027a4141c098ea64c (patch)
treea7ad834387f365dc7717ef3732a6082cd7eee123 /tests/build-utils.scm
parentdcd72906545816938d16af3afca0ffa9e4ce3dcf (diff)
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.
Diffstat (limited to 'tests/build-utils.scm')
-rw-r--r--tests/build-utils.scm34
1 files changed, 34 insertions, 0 deletions
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: