diff options
-rw-r--r-- | module/vcomponent/control.scm | 2 | ||||
-rw-r--r-- | tests/vcomponent-control.scm | 25 |
2 files changed, 25 insertions, 2 deletions
diff --git a/module/vcomponent/control.scm b/module/vcomponent/control.scm index 3bdecc5a..34a2cf95 100644 --- a/module/vcomponent/control.scm +++ b/module/vcomponent/control.scm @@ -35,5 +35,3 @@ (lambda () body ...) (lambda () (restore-values! htable component (quote (key ...))))))])) ; Out guard -;;; TODO test that restore works, at all -;;; Test that non-local exit and return works 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)))) |