aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHerman Rimm <herman@rimm.ee>2024-02-20 21:45:12 +0100
committerLudovic Courtès <ludo@gnu.org>2024-02-23 19:02:16 +0100
commit50e514c1bc674b1c36344407c8c4b418d17759c5 (patch)
tree7e5ed98db478efa5492f672e8a2a8b68254b8568 /tests
parentbabd39e84389c544e8dab44be8ddec57e52709c9 (diff)
downloadguix-50e514c1bc674b1c36344407c8c4b418d17759c5.tar
guix-50e514c1bc674b1c36344407c8c4b418d17759c5.tar.gz
utils: Add find-definition-insertion-location procedure.
* guix/utils.scm (find-definition-insertion-location): Add and export procedure. * tests/utils.scm ("find-definition-insertion-location"): Add test. Change-Id: Ie17e1b4a94790f58518ce121411a38d357f49feb Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/utils.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm
index cd54112846..52f3b58ede 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -288,6 +288,20 @@ skip these tests."
`(define-public package-1 'package))
(call-with-input-file temp-file get-string-all)))
+(test-equal "find-definition-insertion-location"
+ (list `((filename . ,temp-file) (line . 0) (column . 0))
+ `((filename . ,temp-file) (line . 5) (column . 0))
+ #f)
+ (begin
+ (call-with-output-file temp-file
+ (lambda (port)
+ (display "(define-public package-1\n 'foo)\n\n" port)
+ (display "(define foo 'bar)\n\n" port)
+ (display "(define-public package-2\n 'baz)\n" port)))
+ (map (lambda (term)
+ (find-definition-insertion-location temp-file term))
+ (list 'package 'package-1 'package-2))))
+
(test-equal "string-distance"
'(0 1 1 5 5)
(list