aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-combinators)
  #:use-module (guix combinators)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 vlist))

(test-begin "combinators")

(test-equal "fold2, 1 list"
    (list (reverse (iota 5))
          (map - (reverse (iota 5))))
  (call-with-values
      (lambda ()
        (fold2 (lambda (i r1 r2)
                 (values (cons i r1)
                         (cons (- i) r2)))
               '() '()
               (iota 5)))
    list))

(test-equal "fold2, 2 lists"
    (list (reverse '((a . 0) (b . 1) (c . 2) (d . 3)))
          (reverse '((a . 0) (b . -1) (c . -2) (d . -3))))
  (call-with-values
      (lambda ()
        (fold2 (lambda (k v r1 r2)
                 (values (alist-cons k v r1)
                         (alist-cons k (- v) r2)))
               '() '()
               '(a b c d)
               '(0 1 2 3)))
    list))

(let* ((tree (alist->vhash
              '((0 2 3) (1 3 4) (2) (3 5 6) (4 6) (5) (6))
              hashq))
       (add-one (lambda (_ r) (1+ r)))
       (tree-lookup (lambda (n) (cdr (vhash-assq n tree)))))
  (test-equal "fold-tree, single root"
    5 (fold-tree add-one 0 tree-lookup '(0)))
  (test-equal "fold-tree, two roots"
    7 (fold-tree add-one 0 tree-lookup '(0 1)))
  (test-equal "fold-tree, sum"
    16 (fold-tree + 0 tree-lookup '(0)))
  (test-equal "fold-tree, internal"
    18 (fold-tree + 0 tree-lookup '(3 4)))
  (test-equal "fold-tree, cons"
    '(1 3 4 5 6)
    (sort (fold-tree cons '() tree-lookup '(1)) <))
  (test-equal "fold-tree, overlapping paths"
    '(1 3 4 5 6)
    (sort (fold-tree cons '() tree-lookup '(1 4)) <))
  (test-equal "fold-tree, cons, two roots"
    '(0 2 3 4 5 6)
    (sort (fold-tree cons '() tree-lookup '(0 4)) <))
  (test-equal "fold-tree-leaves, single root"
    2 (fold-tree-leaves add-one 0 tree-lookup '(1)))
  (test-equal "fold-tree-leaves, single root, sum"
    11 (fold-tree-leaves + 0 tree-lookup '(1)))
  (test-equal "fold-tree-leaves, two roots"
    3 (fold-tree-leaves add-one 0 tree-lookup '(0 1)))
  (test-equal "fold-tree-leaves, two roots, sum"
    13 (fold-tree-leaves + 0 tree-lookup '(0 1))))

(test-end)

am. The PO4A defined here can be used in Makefiles (e.g. po/doc/local.mk below). The po4a command integrates the functionality of po4a-updatepo and is currently recommended for use [1]. The po4a-updatepo command has been replaced by the po4a command and are not used from anywhere. * po/doc/local.mk (%D%/%.pot): Use a po4a command instead of the po4a-updatepo for the POT generation. This eliminates the warning of po4a-updatepo; "po4a-updatepo is deprecated. The unified po4a(1) program is more convenient and less error prone." Here, the file paths are passed using variables. This is because the po4a command needs to be executed for each language and each file. Dummy values are passed for those that are not needed to update the POT file. * po/doc/po4a.cfg: Add a po4a config file for the POT generation. The po4a command requires a configulation file. [1] https://po4a.org/man/man7/po4a.7.php.en#lbAS Change-Id: Ica39a0d1f77b6a64d37c592ac2e693319443d3c5 Signed-off-by: Florian Pelz <pelzflorian@pelzflorian.de> 2024-05-01nls: Update translations.Florian Pelz * po/packages/sv.po: New file. * po/packages/LINGUAS: Add it. Change-Id: I2ad4dfcb935ba0a4e79c15b86cee6826c6580729 2024-04-14maint: Use reproducible Git timestamp for POT-Creation-Date.Janneke Nieuwenhuizen * po/doc/local.mk (%D%/%.pot): Replace POT-Creation-Date using timestamp from Git. (%D%/guix-manual.pot): Likewise. Change-Id: I1b7f8cc147084c1804deb7be9d36e5eeda2599cb 2024-04-01nls: Update translations.Florian Pelz * po/guix/ar.po: New file. * po/guix/LINGUAS: Add 'ar'. * po/doc/guix-cookbook.pt_BR.po: New file. * po/doc/local.mk: Add 'pt_BR' cookbook. * doc/local.mk: Add 'pt_BR' cookbook. * doc/htmlxref.cnf: Update URLs for cookbook. * doc/build.scm (%cookbook-languages): Add 'ko', 'pt_BR'. * doc/guix-cookbook.texi (Top): Mention 'ko', 'pt_BR' cookbook. Change-Id: Id1846ca100263b3fc1fa2ed52654c670270ee809 2024-02-29nls: Update translations.Florian Pelz Change-Id: Ic1506db5813880153b6def005011618dc4529e8f 2024-02-01nls: Update translations.Florian Pelz Change-Id: I42b5d41bdd5cd1b096c977e132b7a85992223402 2024-01-01nls: Update translations.Florian Pelz Change-Id: Ib407fd37896cc8653f5bfb1f76dba9dc775c8c10 2023-12-01nls: Update translations.Florian Pelz * po/guix/ca.po: New file. * po/guix/LINGUAS: Add ca.$ Change-Id: Ibae3f58ba702d7c5a4fafdd59a19f70aa8e18212 2023-10-31nls: Update translations.Florian Pelz Change-Id: I432aec0ea31ead192d6444c96dc42038f5c7ab9a 2023-10-05doc: Fix channel name typo.Nikolaos Chatzikonstantinou When the manual has "variant-personal-packages", it actually refers to the channel "variant-packages", as it is named so elsewhere. To correct this, I ran the command grep -r -l variant-personal-packages | xargs \ sed -i 's/variang-personal-packages/variant-packages/g' * doc/guix.texi (Specifying Additional Channels): Fix channel name typo. * po/doc/guix-manual.de.po: Fix channel name typo. * po/doc/guix-manual.es.po: Fix channel name typo. * po/doc/guix-manual.fr.po: Fix channel name typo. * po/doc/guix-manual.pt_BR.po: Fix channel name typo. * po/doc/guix-manual.ru.po: Fix channel name typo. * po/doc/guix-manual.zh_CN.po: Fix channel name typo. Signed-off-by: Nikolaos Chatzikonstantinou <nchatz314@gmail.com> Signed-off-by: Ludovic Courtès <ludo@gnu.org> 2023-09-30nls: Update translations.Florian Pelz 2023-08-31nls: Update translations.Florian Pelz 2023-07-31nls: Update translations.Florian Pelz 2023-06-30nls: Update translations.Florian Pelz * po/packages/ja.po: New file. * po/packages/LINGUAS: Add it. 2023-05-31nls: Update translations.Florian Pelz * doc/guix-cookbook.texi (Top): Mention Slovak. 2023-03-07nls: Update translations.Julien Lepiller 2023-01-05nls: Update translations.Julien Lepiller * po/guix/ka.po: New file. * po/guix/LINGUAS: Add it. * po/packages/uk.po: New file. * po/packages/LINGUAS: Add it. 2022-12-15doc: Use VM image file name consistently.Ludovic Courtès Previously, what "/tmp/qemu-image" refers to could be unclear at first. * doc/guix.texi (Running Guix in a VM): Use the original image file name instead of /tmp/qemu-image. * po/doc/guix-manual.de.po, po/doc/guix-manual.es.po, po/doc/guix-manual.fr.po, po/doc/guix-manual.pt_BR.po, po/doc/guix-manual.ru.po, po/doc/guix-manual.zh_CN.po: Adjust accordingly. 2022-12-04nls: Update translations.Julien Lepiller po/packages/vi.po: New file. po/packages/LINGUAS: Add it. 2022-11-04nls: Update translations.Julien Lepiller * po/guix/lt.po: New file. * po/guix/LINGUAS: Add lt. 2022-10-08po: Fix syntax error in French translation.Ricardo Wurmus * po/doc/guix-manual.fr.po: Add missing space. 2022-10-08po: Fix syntax error in German translation.Ricardo Wurmus * po/doc/guix-manual.de.po: Remove double wrapping of @uref. 2022-10-06nls: Update translations.Julien Lepiller 2022-09-04nls: Update translations.Julien Lepiller 2022-08-10nls: Update translations.Julien Lepiller po/guix/bn.po: New file. po/guix/LINGUAS: Add it. 2022-07-09nls: Update translations.Julien Lepiller po/guix/tr.po: New file. po/guix/LINGUAS: Add it. 2022-06-04nls: Update translations.Julien Lepiller po/packages/tr.po: New file. po/packages/LINGUAS: Add it. 2022-05-01nls: Update translations.Julien Lepiller po/guix/ja.po: New file. po/guix/LINGUAS: Add it.