diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-02-23 03:22:04 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-02-23 05:40:51 +0100 |
commit | 11ebbefb55127eee884a9080ece4aa201ad579c1 (patch) | |
tree | 8b7ee9a89f9d901b06e23d186cecea5e8a61327c /tests/test/vcomponent.scm | |
parent | Start using (vcomponent create) in tests. (diff) | |
download | calp-11ebbefb55127eee884a9080ece4aa201ad579c1.tar.gz calp-11ebbefb55127eee884a9080ece4aa201ad579c1.tar.xz |
Change child/parent interface for vcomponent.
Diffstat (limited to 'tests/test/vcomponent.scm')
-rw-r--r-- | tests/test/vcomponent.scm | 32 |
1 files changed, 28 insertions, 4 deletions
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)) + ))) |