]> gitweb.factorcode.org Git - factor.git/commitdiff
irc.client: add test
authorBruno Deferrari <utizoc@gmail.com>
Sat, 7 Mar 2009 22:54:28 +0000 (20:54 -0200)
committerBruno Deferrari <utizoc@gmail.com>
Thu, 9 Apr 2009 02:13:17 +0000 (23:13 -0300)
extra/irc/client/client-tests.factor

index 07b9df2ab7f7d38453bb8bf328ceb13be8cf17b0..9e96cc249bfed14c44b11ab5d42c4501e9c5f481 100644 (file)
@@ -34,6 +34,7 @@ M: mb-writer dispose drop ;
 : %add-named-chat ( chat -- ) irc> attach-chat ;
 : %push-line ( line -- ) irc> stream>> in>> push-line yield ;
 : %join ( channel -- ) <irc-channel-chat> irc> attach-chat ;
+: %pop-output-line ( -- string ) irc> stream>> out>> lines>> pop ;
 
 : read-matching-message ( chat quot: ( msg -- ? ) -- irc-message )
     [ in-messages>> 0.1 seconds ] dip mailbox-get-timeout? ;
@@ -79,8 +80,7 @@ M: mb-writer dispose drop ;
 
 ! Test join
 [ { "JOIN #factortest" } [
-      "#factortest" %join
-      irc> stream>> out>> lines>> pop
+      "#factortest" %join %pop-output-line
   ] unit-test
 ] with-irc
 
@@ -221,3 +221,10 @@ M: mb-writer dispose drop ;
       [ participant-changed? ] read-matching-message
   ] unit-test
 ] with-irc
+
+! Send privmsg
+[ { "PRIVMSG #factortest :hello" } [
+      "#factortest" <irc-channel-chat> [ %add-named-chat ] keep
+      "hello" swap speak %pop-output-line
+  ] unit-test
+] with-irc