aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/vcomponent/vcomponent-control.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-10-02 19:26:40 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-10-02 19:28:44 +0200
commit712654d4c023a2ab13190c6905d313e0ba897965 (patch)
treeb8505b420d6621022fa6a46271340071d8881322 /tests/unit/vcomponent/vcomponent-control.scm
parentMade displayln into a library export. (diff)
downloadcalp-712654d4c023a2ab13190c6905d313e0ba897965.tar.gz
calp-712654d4c023a2ab13190c6905d313e0ba897965.tar.xz
Rewrite test running system.
Diffstat (limited to 'tests/unit/vcomponent/vcomponent-control.scm')
-rw-r--r--tests/unit/vcomponent/vcomponent-control.scm36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/unit/vcomponent/vcomponent-control.scm b/tests/unit/vcomponent/vcomponent-control.scm
new file mode 100644
index 00000000..7ebafa3d
--- /dev/null
+++ b/tests/unit/vcomponent/vcomponent-control.scm
@@ -0,0 +1,36 @@
+;;; Commentary:
+;; Tests that with-replaced-properties work.
+;;; Code:
+
+(define-module (test vcomponent-control)
+ :use-module (srfi srfi-64)
+ :use-module (srfi srfi-88)
+ :use-module (vcomponent create)
+ :use-module ((vcomponent util control)
+ :select (with-replaced-properties))
+ :use-module ((vcomponent formats ical parse)
+ :select (parse-calendar))
+ :use-module ((vcomponent base) :select (prop)))
+
+(define ev (vcomponent 'DUMMY x-key: "value"))
+
+(test-group "With replaced properties"
+ ;; Test that temoraries are set and restored
+ (test-equal "value" (prop ev 'X-KEY))
+
+ (with-replaced-properties
+ (ev (X-KEY "other"))
+ (test-equal "other" (prop ev 'X-KEY)))
+
+ (test-equal "value" (prop ev 'X-KEY)))
+
+;; Test that they are restored on non-local exit
+(test-group "With replaced properties when throwing"
+ (catch #t
+ (lambda ()
+ (with-replaced-properties
+ (ev (X-KEY "other"))
+ (throw 'any)))
+ (lambda _ (test-equal "value" (prop ev 'X-KEY)))))
+
+'((vcomponent util control))