aboutsummaryrefslogtreecommitdiff
path: root/tests/test/lens.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-04-24 21:11:16 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-04-24 21:11:16 +0200
commit987b1e0e574007b272b04605f3b57d420bde4fb4 (patch)
tree003c430e6a46cbcff09f60d9783f861506115de8 /tests/test/lens.scm
parentAdd tests for href stuff. (diff)
parentDocument type and object system. (diff)
downloadcalp-987b1e0e574007b272b04605f3b57d420bde4fb4.tar.gz
calp-987b1e0e574007b272b04605f3b57d420bde4fb4.tar.xz
Merge remote-tracking branch 'origin/new-object-system' into datarewrite-structures
Diffstat (limited to 'tests/test/lens.scm')
-rw-r--r--tests/test/lens.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test/lens.scm b/tests/test/lens.scm
new file mode 100644
index 00000000..0797e3aa
--- /dev/null
+++ b/tests/test/lens.scm
@@ -0,0 +1,21 @@
+(define-module (test lens)
+ :use-module (srfi srfi-64)
+ :use-module (srfi srfi-64 test-error)
+ :use-module (srfi srfi-88)
+ :use-module (hnh util lens))
+
+
+(define first (ref 0))
+
+(test-equal '((1)) (first '(((1)))))
+(test-equal '((2)) (set '(((1))) (compose-lenses first first) 2))
+(test-equal '(((2))) (set '(((1))) (compose-lenses first first first) 2))
+
+
+;; (list-change (iota 10) 5 'Hello)
+;; => (0 1 2 3 4 Hello 6 7 8 9)
+
+(test-equal '(1 (10) 3) (set '(1 (2) 3) (compose-lenses (ref 1) (ref 0)) 10))
+(test-equal '(1 (10) 3) (set '(1 (2) 3) (ref 1) (ref 0) 10))
+
+;; (set (list (iota 10)) first first 11)