aboutsummaryrefslogtreecommitdiff
path: root/tests/combinators.scm
blob: 1e4bb236b72af1767c899ddb7d15651e4246262c (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
;;; 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)

-flags>: Add “builtin_brotli=no”. [inputs]: Add brotli. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> TakeV 2023-07-30gnu: renpy: Fix image reference paths....The current approach to fixing paths is flawed in that it affects too many of them. See <https://issues.guix.gnu.org/issue/64925#4> for a detailed report of the current defect. gnu/packages/game-development.scm: (renpy)[drop-game-from-paths]: Only drop game from paths that also have “gui7”. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Jesse Gibbons 2023-07-16gnu: godot: Update to 4.1.1....* gnu/packages/game-development.scm (godot): Update to 4.1.1. Tobias Geerinckx-Rice 2023-07-16gnu: mygui: Update to 3.4.2....* gnu/packages/game-development.scm (mygui): Update to 3.4.2. (mygui-gl)[inputs]: Add libglvnd, and a union of sdl2 and sdl2-image. Tobias Geerinckx-Rice 2023-07-16gnu: ode: Update to 0.16.4....* gnu/packages/game-development.scm (ode): Update to 0.16.4. Tobias Geerinckx-Rice 2023-07-09gnu: Remove top-level (guix build utils) import....* gnu/packages/game-development.scm: Don't import (guix build utils) here. Tobias Geerinckx-Rice 2023-07-14gnu: godot: Update to 4.1. Rename godot@3 to godot-lts....* gnu/packages/game-development.scm (godot): Update to 4.1. [source]: Update snippet: remove embree and enet; add amd-fsr, astcenc, basis_universal, brotli, linuxbsd_headers, etcpak, meshoptimizer, msdfgen, noise, openxr, rvo2, spirv-reflect, thorvg, volk, vulkan. [arguments]: Remove #:scons. Update #:scons-flags to unbundle more libraries. [phases]: Remove 'build-headless phase (headless is no longer has a separate build). Add 'fix-dl-open-paths and 'unbundle-xkbcommon phases. In 'install phase, remove headless output. Update 'wrap phase to remove eudev. [outputs]: Remove headless. [inputs]: Add dbus, embree, enet, fontconfig, glslang, libpng, harfbuzz, icu4c, libxkbcommon, openxr, speech-dispatcher, vulkan-loader, zlib. Remove bullet. Rename freetype to freetype-with-brotli. (godot-lts): New variable. godot@3 is the LTS release. * gnu/packages/games.scm (superstarfighter)[native-inputs]: Use it. [inputs]: Use it. John Kehayias 2023-07-11gnu: guile-chickadee: Change license to Apache 2.0....* gnu/packages/game-development.scm (guile-chickadee)[license]: Change to Apache 2.0 (asl2.0). Signed-off-by: Ludovic Courtès <ludo@gnu.org> Morgan Smith 2023-07-09gnu: ode: Skip tests when cross-compiling....* gnu/packages/game-development.scm (ode)[arguments]: Adjust #:tests? to skip tests when cross-compiling. Efraim Flashner 2023-06-20gnu: recastnavigation: Update to 1.6.0....* gnu/packages/game-development.scm (recastnavigation): Update to 1.6.0. Signed-off-by: Christopher Baines <mail@cbaines.net> Kaelyn Takata 2023-05-28gnu: python-renpy: Use G-Expressions....* gnu/packages/game-development.scm (python-renpy)[arguments]: Convert to list of G-Expressions. Liliana Marie Prikler 2023-05-28gnu: python-renpy: Update to 8.1.0....* gnu/packages/game-development.scm (python-renpy): Update to 8.1.0. [source]: No longer unbundle fribidi. Drop sync service and report as official version. [arguments]<#:phases>: Drop ‘fix-include-paths’. [propagated-inputs]: Add python-ecdsa. Liliana Marie Prikler 2023-05-28gnu: python-pygame-sdl2: Use G-Expressions....* gnu/packages/game-development.scm (python-pygame-sdl2)[arguments]: Convert to list of G-Expressions. Liliana Marie Prikler 2023-05-28gnu: python-pygame-sdl2: Update to 2.1.0-for-renpy-8.1.0....* gnu/packages/game-development.scm (python-pygame-sdl2): Update to 2.1.0-for-renpy-8.1.0. Liliana Marie Prikler 2023-05-24gnu: guile-chickadee: Update to 0.10.0....* gnu/packages/game-development.scm (guile-chickadee): Update to 0.10.0. David Thompson 2023-05-19gnu: openmw: Fix build on glibc 2.34 and newer....* gnu/packages/patches/openmw-assume-nonconst-SIGSTKSZ.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/game-development.scm (openmw)[source]<patches>: Use it here. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Kaelyn Takata 2023-05-19gnu: recastnavigation: Update to commit 6d1f971....* gnu/packages/game-development.scm (recastnavigation): Update to commit 6d1f971. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Kaelyn Takata 2023-05-14gnu: Add bbcsdl....* gnu/packages/game-development.scm (bbcsdl): New variable. 宋文武 2023-05-13gnu: raylib: Fix audio and use system glfw....* gnu/packages/game-development.scm (raylib)[inputs]: Use glfw and pluseaudio. [arguments]: Set flags for glfw and pulseaudio. 宋文武 2023-05-13gnu: raylib: Update to 4.5.0....* gnu/packages/game-development.scm (raylib): Update to 4.5.0. 宋文武