From 773e515c583a7707319459390f61a0fa1db06eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 23 May 2020 12:55:30 +0200 Subject: Add tests for with-replaced-attrs. --- tests/vcomponent-control.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/vcomponent-control.scm (limited to 'tests') diff --git a/tests/vcomponent-control.scm b/tests/vcomponent-control.scm new file mode 100644 index 00000000..318c4335 --- /dev/null +++ b/tests/vcomponent-control.scm @@ -0,0 +1,25 @@ +(((vcomponent control) with-replaced-attrs) + ((vcomponent) parse-calendar) + ((vcomponent base) attr)) + + + +(define ev (call-with-input-string + "BEGIN:DUMMY +KEY:value +END:DUMMY" + parse-calendar)) + +;; Test that temoraries are set and restored +(test-equal "value" (attr ev 'KEY)) +(with-replaced-attrs (ev (KEY "other")) + (test-equal "other" (attr ev 'KEY))) +(test-equal "value" (attr ev 'KEY)) + +;; Test that they are restored on non-local exit +(catch #t + (lambda () + (with-replaced-attrs (ev (KEY "other")) + (throw 'any))) + (lambda _ + (test-equal "value" (attr ev 'KEY)))) -- cgit v1.2.3