aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-02-23 03:22:04 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-02-23 05:40:51 +0100
commit11ebbefb55127eee884a9080ece4aa201ad579c1 (patch)
tree8b7ee9a89f9d901b06e23d186cecea5e8a61327c /tests
parentStart using (vcomponent create) in tests. (diff)
downloadcalp-11ebbefb55127eee884a9080ece4aa201ad579c1.tar.gz
calp-11ebbefb55127eee884a9080ece4aa201ad579c1.tar.xz
Change child/parent interface for vcomponent.
Diffstat (limited to 'tests')
-rw-r--r--tests/test/add-and-save.scm2
-rw-r--r--tests/test/vcomponent.scm32
2 files changed, 29 insertions, 5 deletions
diff --git a/tests/test/add-and-save.scm b/tests/test/add-and-save.scm
index 70b8cce2..fb3277bb 100644
--- a/tests/test/add-and-save.scm
+++ b/tests/test/add-and-save.scm
@@ -112,7 +112,7 @@
(test-equal "Correct amount of children in calendar"
- 2 (length (children calendar)))
+ 5 (length (children calendar)))
(define get-events (@@ (vcomponent util instance methods) get-events))
diff --git a/tests/test/vcomponent.scm b/tests/test/vcomponent.scm
index 52e1b6bb..a6989776 100644
--- a/tests/test/vcomponent.scm
+++ b/tests/test/vcomponent.scm
@@ -3,11 +3,13 @@
;;; Code:
(define-module (test vcomponent)
+ :use-module (srfi srfi-17)
:use-module (srfi srfi-64)
:use-module (srfi srfi-88)
:use-module ((vcomponent base)
- :select (prop make-vcomponent add-child! remove-child!
- children)))
+ :select (prop make-vcomponent reparent! abandon!
+ copy-vcomponent
+ type parent children)))
(define ev
(let ((ev (make-vcomponent 'DUMMY)))
@@ -22,7 +24,29 @@
(define calendar (make-vcomponent 'VCALENDAR))
-(add-child! calendar ev)
+(reparent! calendar ev)
(test-equal 1 (length (children calendar)))
-(remove-child! calendar ev)
+(abandon! calendar ev)
(test-equal 0 (length (children calendar)))
+
+
+(test-group "Copy VComponent"
+ (let ((ev1 (make-vcomponent 'A))
+ (ev2 (make-vcomponent 'B))
+ (ev3 (make-vcomponent 'C)))
+ (set! (prop ev3 'TEST) (list 1 2 3))
+ (reparent! ev1 ev2)
+ (reparent! ev2 ev3)
+ (let* ((ev2* (copy-vcomponent ev2))
+ (ev3* (car (children ev2*))))
+ ;; NOTE replace this with `vcomponent=?' if that gets written
+ (test-group "New object is equivalent to old one"
+ (test-equal (type ev2) (type ev2*))
+ (test-equal (length (children ev2)) (length (children ev2*))))
+ (test-eq ev1 (parent ev2))
+
+ (set! (car (prop ev3* 'TEST)) 10)
+ (test-equal "Property values aren't deep copied"
+ '(10 2 3) (prop ev3 'TEST))
+ (test-equal '(10 2 3) (prop ev3* 'TEST))
+ )))