aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/vcomponent/vcomponent-control.scm
blob: f42af4de16d3fdd9f8f6359cfc37e0ad8c9d5276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; 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 base) :select (prop)))

(define ev (create-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))