summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2014-12-16 08:42:21 +0100
committerrekado <rekado@elephly.net>2014-12-16 08:42:21 +0100
commit6feadbd3d86532e0eec51423452f9e29fa369ddc (patch)
tree5729a660d428c82d60cc2203dad968ef9b30b5e1 /spec
parent0012f9809af22a0b3d6774059e718005e63fb464 (diff)
test (and fix) run-handler-loop
Diffstat (limited to 'spec')
-rw-r--r--spec/xmpp.scm22
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/xmpp.scm b/spec/xmpp.scm
index cf61e7c..8a945d1 100644
--- a/spec/xmpp.scm
+++ b/spec/xmpp.scm
@@ -137,4 +137,24 @@
(suite "handle-stanza" (tests))
(suite "register-temp-stanza-handler-for-id" (tests))
(suite "register-stanza-handler" (tests))
-(suite "run-handler-loop" (tests))
+
+(suite "run-handler-loop"
+ (tests
+ (test "does not die when a handler throws an exception" e
+ (assert-false
+ (error? (begin
+ (register-stanza-handler
+ (lambda _ (throw 'some-error "no reason")))
+ (call-with-input-string
+ "<iq from='test' id='123'/><iq from='someone' id='234'/>"
+ run-handler-loop)))))
+ (test "processes all stanzas in the queue" e
+ (assert-equal 2
+ (let ((count 0))
+ (register-stanza-handler
+ (lambda _ (begin (set! count (1+ count))
+ (throw 'some-error "no reason"))))
+ (call-with-input-string
+ "<iq from='test' id='123'/><iq from='someone' id='234'/>"
+ run-handler-loop)
+ count)))))