aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/lib.scm
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-11-03 13:37:15 +0000
committerJustus Winter <[email protected]>2016-11-03 13:43:23 +0000
commit1ec07cbc209f247fd85704f5701564e31aa56d0b (patch)
tree305188a94dc0351cb3bf7f08dceef4ef96790c93 /tests/gpgscm/lib.scm
parentgpgconf: Add a new field to the --query-swdb output. (diff)
downloadgnupg-1ec07cbc209f247fd85704f5701564e31aa56d0b.tar.gz
gnupg-1ec07cbc209f247fd85704f5701564e31aa56d0b.zip
gpgscm,tests: Add new functions to the test environment.
* tests/gpgscm/lib.scm (first, last, powerset): New functions. * tests/gpgscm/tests.scm (interactive-shell): New function. * tests/openpgp/Makefile.am (EXTRA_DIST): Add new file. * tests/openpgp/README: Document 'interactive-shell'. * tests/openpgp/shell.scm: New file. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tests/gpgscm/lib.scm')
-rw-r--r--tests/gpgscm/lib.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index e4ab48303..316eacf87 100644
--- a/tests/gpgscm/lib.scm
+++ b/tests/gpgscm/lib.scm
@@ -42,6 +42,24 @@
((not (p (car l))) #f)
(else (all p (cdr l)))))
+;; Return the first element of a list.
+(define first car)
+
+;; Return the last element of a list.
+(define (last lst)
+ (if (null? (cdr lst))
+ (car lst)
+ (last (cdr lst))))
+
+;; Compute the powerset of a list.
+(define (powerset set)
+ (if (null? set)
+ '(())
+ (let ((rst (powerset (cdr set))))
+ (append (map (lambda (x) (cons (car set) x))
+ rst)
+ rst))))
+
;; Is PREFIX a prefix of S?
(define (string-prefix? s prefix)
(and (>= (string-length s) (string-length prefix))