<commit_before>USING: kernel tools.test accessors arrays sequences qualified
       io.streams.string io.streams.duplex namespaces threads
       calendar irc.client.private concurrency.mailboxes classes ;
EXCLUDE: irc.client => join ;
RENAME: join irc.client => join_
IN: irc.client.tests

! Utilities
: <test-stream> ( lines -- stream )
  "\n" join <string-reader> <string-writer> <duplex-stream> ;

: make-client ( lines -- irc-client )
   "someserver" irc-port "factorbot" f <irc-profile> <irc-client>
   swap [ 2nip <test-stream> f ] curry >>connect ;

: set-nick ( irc-client nickname -- )
     swap profile>> (>>nickname) ;

: with-dummy-client ( quot -- )
     rot with-variable ; inline

! Parsing tests
irc-message new
    ":someuser!n=user@some.where PRIVMSG #factortest :hi" >>line
    "someuser!n=user@some.where" >>prefix
                       "PRIVMSG" >>command
               { "#factortest" } >>parameters
                            "hi" >>trailing
1array
[ ":someuser!n=user@some.where PRIVMSG #factortest :hi"
  string>irc-message f >>timestamp ] unit-test<commit_msg>irc.client: Fix tests<commit_after>USING: kernel tools.test accessors arrays sequences qualified
       io.streams.string io.streams.duplex namespaces threads
       calendar irc.client.private irc.client irc.messages.private
       concurrency.mailboxes classes ;
EXCLUDE: irc.messages => join ;
RENAME: join irc.messages => join_
IN: irc.client.tests

! Utilities
: <test-stream> ( lines -- stream )
  "\n" join <string-reader> <string-writer> <duplex-stream> ;

: make-client ( lines -- irc-client )
   "someserver" irc-port "factorbot" f <irc-profile> <irc-client>
   swap [ 2nip <test-stream> f ] curry >>connect ;

: set-nick ( irc-client nickname -- )
     swap profile>> (>>nickname) ;

: with-dummy-client ( quot -- )
     rot with-variable ; inline

! Parsing tests
irc-message new
    ":someuser!n=user@some.where PRIVMSG #factortest :hi" >>line
    "someuser!n=<EMAIL>" >>prefix
                       "PRIVMSG" >>command
               { "#factortest" } >>parameters
                            "hi" >>trailing
1array
[ ":someuser!n=user@some.where PRIVMSG #factortest :hi"
  string>irc-message f >>timestamp ] unit-test
{'fraction_non_alphanumeric': 0.13540260908681961, 'fraction_numerical': 0.001799370220422852, 'mean_word_length': 2.992818671454219, 'pattern_counts': {'":': 4, '<': 18, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7540533', 'n_tokens_mistral': 735, 'n_tokens_neox': 713, 'n_words': 173}