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)

Delete variable. Maxim Cournoyer 2022-05-31gnu: Remove python2-tzdata....* gnu/packages/time.scm (python2-tzdata): Delete variable. Maxim Cournoyer 2022-05-31gnu: Remove python2-aniso8601....* gnu/packages/time.scm (python2-aniso8601): Delete variable. Maxim Cournoyer 2022-05-31gnu: Remove python2-parsedatetime....* gnu/packages/time.scm (python2-parsedatetime): Delete variable. Maxim Cournoyer 2022-05-31gnu: Remove python2-monotonic....* gnu/packages/time.scm (python2-monotonic): Delete variable. Maxim Cournoyer 2022-05-16Merge branch 'master' into stagingEfraim Flashner 2022-05-15gnu: Fix the build of wicd....Fixes <https://issues.guix.gnu.org/55440>. * gnu/packages/check.scm (python2-pytest-cov, python2-freezegun): Define without package-with-python2. * gnu/packages/python-xyz.scm (python2-babel): Likewise. * gnu/packages/time.scm (python2-dateutil): Likwise. Leo Famulari 2022-05-08gnu: python-pytz: Update to 2022.1....* gnu/packages/time.scm (python-pytz): Update to 2022.1. Leo Famulari 2022-02-13gnu: python-iso8601: Update to 1.0.2....* gnu/packages/time.scm (python-iso8601): Update to 1.0.2. [native-inputs]: Add PYTHON-PYTZ. [home-page]: Update to current. [properties]: New field. * gnu/packages/time.scm (python2-iso8601): Update to 0.1.16. Marius Bakke 2022-01-24gnu: python-parsedatetime: Update to 2.6....* gnu/packages/time.scm (python-parsedatetime): Update to 2.6. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Pradana AUMARS 2022-01-14gnu: python-pendulum: Add setup.py to fix build....* gnu/packages/time.scm (python-pendulum)[arguments]: Add "setup.py" to fix build. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Foo Chuan Wei 2022-01-12gnu: Add tz....* gnu/packages/time.scm (tz): New variable. Co-authored-by: jgart <jgart@dismail.de> Co-authored-by: Jorge Acereda <jacereda@gmail.com> Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Guix Together 2021-12-17gnu: datefudge: Add a backup source URI....This tarball disappeared upstream. * gnu/packages/time.scm (datefudge)[source]: Add backup URI. Leo Famulari 2021-12-13gnu: Simplify package inputs....This commit was obtained by running: ./pre-inst-env guix style without any additional argument. Ludovic Courtès 2021-11-18gnu: python-aniso8601: Update to 9.0.1....* gnu/packages/time.scm (python-aniso8601): Update to 9.0.1. [propagated-inputs]: Remove. Ludovic Courtès 2021-11-11gnu: python-dateutil: Update to 2.8.2....* gnu/packages/time.scm (python-dateutil): Update to 2.8.2. Maxim Cournoyer 2021-10-20gnu: python-arrow: Move python-pytz to native-inputs....* gnu/packages/time.scm (python-arrow)[propagated-inputs]: Move python-pytz to ... [native-inputs]: ... here since it is only used for testing purposes. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> jgart 2021-07-09gnu: python-arrow: Honor #:tests? in 'check' phase....* gnu/packages/time.scm (python-arrow)[arguments]: 'check' phase honors #:tests?. Ludovic Courtès 2021-07-09gnu: python-arrow: Update to 1.1.1....* gnu/packages/time.scm (python-arrow): Update to 1.1.1. Kris Fremen 2021-06-08gnu: python2-pendulum: Remove package....* gnu/packages/time.scm (python2-pendulum): Remove variable. Signed-off-by: Leo Famulari <leo@famulari.name> zimoun 2021-03-26gnu: python-pytz: Update to 2021.1....* gnu/packages/time.scm (python-pytz): Update to 2021.1. Leo Famulari 2021-03-26gnu: python-pytzdata: Update to 2020.1....* gnu/packages/time.scm (python-pytzdata): Update to 2020.1. Leo Famulari 2021-03-23gnu: python2-arrow: Remove package....* gnu/packages/time.scm (python2-arrow): Delete. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> zimoun 2021-03-18gnu: Add countdown....* gnu/packages/time.scm (countdown): New variable. Also adds copyright, adds necessary module dependencies, and sorts them alphabetically. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Ryan Prior via Guix-patches via 2021-02-15gnu: python-tzlocal: Update to 2.1....* gnu/packages/time.scm (python-tzlocal): Update to 2.1. [arguments]: Adjust custom 'fix-symlink-tests phase for code changes. Also skip other known-to-fail test. Efraim Flashner 2021-02-08gnu: python-arrow: Adjust test suite....* gnu/packages/time.scm (python-arrow)[arguments]: Skip test broken by dependant package. Efraim Flashner 2020-12-21Merge branch 'ungrafting' into stagingMarius Bakke 2020-12-13gnu: python-pytz: Update to 2020.4....* gnu/packages/time.scm (python-pytz): Update to 2020.4. Marius Bakke 2020-12-13gnu: python-iso8601: Update to 0.1.13....* gnu/packages/time.scm (python-iso8601): Update to 0.1.13. [arguments]: New field. Marius Bakke 2020-12-13gnu: python-arrow: Update to 0.17.0....* gnu/packages/time.scm (python-arrow): Update to 0.17.0. [arguments]: Replace check phase to invoke pytest. [native-inputs]: Add python-pytest, python-pytest-cov and python-pytest-mock. [propagated-inputs]: Add python-pytz. [home-page]: Update. Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Tanguy Le Carrour