diff options
author | Herman Rimm <herman@rimm.ee> | 2024-02-20 21:45:11 +0100 |
---|---|---|
committer | Josselin Poiret <dev@jpoiret.xyz> | 2024-03-09 15:55:46 +0100 |
commit | 6ae32db25ee0e1064f37cd754aa12e7e0560237f (patch) | |
tree | ad863a297a51dc22d1f43aeba0b7895f7f910c87 /tests | |
parent | 086649833b3264fc9d28f2b8d222158bcfc79ef4 (diff) |
utils: Add insert-expression procedure.
* guix/utils.scm (define-module): Use (guix read-print) and export
(insert-expression).
(insert-expression): Add procedure.
* tests/utils.scm ("insert-expression"): Add test.
Change-Id: I971a43a78aa6ecaaef33c1a7a0db4b287eb85036
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.scm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index 5664165c85..cd54112846 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be> ;;; Copyright © 2023 Foundation Devices, Inc. <hello@foundationdevices.com> +;;; Copyright © 2024 Herman Rimm <herman@rimm.ee> ;;; ;;; This file is part of GNU Guix. ;;; @@ -274,6 +275,19 @@ skip these tests." string-reverse) (call-with-input-file temp-file get-string-all))) +(test-equal "insert-expression" + "(define-public package-1\n 'package)\n +(define-public package-2\n 'package)\n" + (begin + (call-with-output-file temp-file + (lambda (port) + (display "(define-public package-2\n 'package)\n" port))) + (insert-expression `((filename . ,temp-file) + (line . 0) + (column . 0)) + `(define-public package-1 'package)) + (call-with-input-file temp-file get-string-all))) + (test-equal "string-distance" '(0 1 1 5 5) (list |