package: allow users to upgrade the whole system by not providing a regexp.
[jackhill/guix/guix.git] / tests / ui.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19
20 (define-module (test-ui)
21 #:use-module (guix ui)
22 #:use-module (srfi srfi-1)
23 #:use-module (srfi srfi-64))
24
25 ;; Test the (guix ui) module.
26
27 (define %paragraph
28 "GNU Guile is an implementation of the Scheme programming language, with
29 support for many SRFIs, packaged for use in a wide variety of environments.
30 In addition to implementing the R5RS Scheme standard and a large subset of
31 R6RS, Guile includes a module system, full access to POSIX system calls,
32 networking support, multiple threads, dynamic linking, a foreign function call
33 interface, and powerful string processing.")
34
35 \f
36 (test-begin "ui")
37
38 (test-assert "fill-paragraph"
39 (every (lambda (column)
40 (every (lambda (width)
41 (every (lambda (line)
42 (<= (string-length line) width))
43 (string-split (fill-paragraph %paragraph
44 width column)
45 #\newline)))
46 '(15 30 35 40 45 50 60 70 80 90 100)))
47 '(0 5)))
48
49 (test-assert "fill-paragraph, consecutive newlines"
50 (every (lambda (width)
51 (any (lambda (line)
52 (string-prefix? "When STR" line))
53 (string-split
54 (fill-paragraph (procedure-documentation fill-paragraph)
55 width)
56 #\newline)))
57 '(15 20 25 30 40 50 60)))
58
59 (test-equal "fill-paragraph, large unbreakable word"
60 '("Here is a" "very-very-long-word"
61 "and that's" "it.")
62 (string-split
63 (fill-paragraph "Here is a very-very-long-word and that's it."
64 10)
65 #\newline))
66
67 (test-end "ui")
68
69 \f
70 (exit (= (test-runner-fail-count (test-runner-current)) 0))