mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 20:30:28 +02:00
Add new fluid tests.
* test-suite/tests/fluids.test ("initial fluid values")["initial value is inherited from parent thread"]: New test. ("fluid values are thread-local"): New test.
This commit is contained in:
parent
e2cf8eb921
commit
c02924d02b
1 changed files with 25 additions and 1 deletions
|
@ -27,7 +27,19 @@
|
||||||
|
|
||||||
(with-test-prefix "initial fluid values"
|
(with-test-prefix "initial fluid values"
|
||||||
(pass-if "fluid-ref uninitialized fluid is #f"
|
(pass-if "fluid-ref uninitialized fluid is #f"
|
||||||
(not (fluid-ref a))))
|
(not (fluid-ref a)))
|
||||||
|
|
||||||
|
(pass-if "initial value is inherited from parent thread"
|
||||||
|
(if (provided? 'threads)
|
||||||
|
(let ((f (make-fluid)))
|
||||||
|
(fluid-set! f 'initial)
|
||||||
|
(let ((child (call-with-new-thread
|
||||||
|
(lambda ()
|
||||||
|
(let ((init (fluid-ref f)))
|
||||||
|
(fluid-set! f 'new)
|
||||||
|
(list init (fluid-ref f)))))))
|
||||||
|
(equal? '(initial new) (join-thread child))))
|
||||||
|
(throw 'unresolved))))
|
||||||
|
|
||||||
(with-test-prefix "with-fluids with non-fluid"
|
(with-test-prefix "with-fluids with non-fluid"
|
||||||
(pass-if-exception "exception raised if nonfluid passed to with-fluids"
|
(pass-if-exception "exception raised if nonfluid passed to with-fluids"
|
||||||
|
@ -56,6 +68,18 @@
|
||||||
(eqv? (fluid-ref a) 2))
|
(eqv? (fluid-ref a) 2))
|
||||||
(eqv? (fluid-ref a) #f))))
|
(eqv? (fluid-ref a) #f))))
|
||||||
|
|
||||||
|
(pass-if "fluid values are thread-local"
|
||||||
|
(if (provided? 'threads)
|
||||||
|
(let ((f (make-fluid)))
|
||||||
|
(fluid-set! f 'parent)
|
||||||
|
(let ((child (call-with-new-thread
|
||||||
|
(lambda ()
|
||||||
|
(fluid-set! f 'child)
|
||||||
|
(fluid-ref f)))))
|
||||||
|
(and (eq? (join-thread child) 'child)
|
||||||
|
(eq? (fluid-ref f) 'parent))))
|
||||||
|
(throw 'unresolved)))
|
||||||
|
|
||||||
(pass-if "fluids are GC'd"
|
(pass-if "fluids are GC'd"
|
||||||
|
|
||||||
(let ((g (make-guardian)))
|
(let ((g (make-guardian)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue