insert ./lib/join-empty
# for: join-channel-0, join-channel-1, join-empty
insert ./lib/part
+# for: exit-channel, part, parts-core, quit
insert ./lib/privmsg
insert ./lib/retry-in
insert ./lib/servermsglogged
insert ./lib/user-set-to
× part-empty
-insert part :-3 +0 USERIDS_CLEAR :cleared
-log CHAN_WIN_ID $ foo!~baz@baz.bar.foo parts
-insert part -2:
+insert part : + USERIDS_CLEAR :cleared
× topic-set-to
log 1 $ channels:CHANNEL:topic set to: [Topic(what='NEWTOPIC', who=NickUserHost(nick='baz', user='~baz', host='baz.baz'))]
× reconnect
> /reconnect
-insert attempting-to-connected : +1 WIN_IDS :2,3,4
-insert caps-neg-empty : +0
-insert 001-setting-nick : +0
+insert attempting-to-connected : + WIN_IDS :2,3,4
+insert caps-neg-empty : +
+insert 001-setting-nick : +
log 1 > JOIN :#ch_test0
insert usermode
-insert servermsglogged : +0 MSG ::foo!~baz@baz.bar.foo JOIN #ch_test0
-insert join-empty : +0 CHANNEL :#ch_test0
+insert servermsglogged : + MSG ::foo!~baz@baz.bar.foo JOIN #ch_test0
+insert join-empty : + CHAN_WIN_ID=3 CHANNEL :#ch_test0
+
+× join-already-in
+> /join TARGET
+log LOG_WIN_ID $ already in that channel
+
+× part-other
+insert servermsglogged : + MSG ::NICK!~NICK@NICK.NICK PART :#ch_test0
+insert parts-core : + exitMSG= exitPREFIX= USERIDS_CLEAR=set§to:§REMAINING_IDS CHANNEL=#ch_test0 CHAN_WIN_ID=3 § :
× ×--------------------------
log 2 $ not sending, since not in channel
# check join with minimum context (no topic, no other users etc.)
-insert join-empty : +0 CHANNEL :#ch_test0
+insert join-empty : + CHAN_WIN_ID=3 CHANNEL :#ch_test0
# check privmsg into channel from other window only works by direct addressing
> msg_test1
log 2 # invalid prompt command: not prefixed by /
-insert privmsg : +1 TARGET=#ch_test0 TXT :msg_test1
+insert privmsg : + TARGET_WIN_ID=3 TARGET=#ch_test0 TXT :msg_test1
# check from within channel window privmsg works directly and indirectly
> /window 3
-insert privmsg : +1 TARGET=#ch_test0 TXT :msg_test2
+insert privmsg : + TARGET_WIN_ID=3 TARGET=#ch_test0 TXT :msg_test2
> msg_test3
-insert privmsg 1: +1 TARGET=#ch_test0 TXT :msg_test3
+insert privmsg 1: + TARGET_WIN_ID=3 TARGET=#ch_test0 TXT :msg_test3
# check /part and that it only works from within channel window, and if already in channel
> /window 2
> /part
log 2 # invalid prompt command: /part unknown
> /window 3
-insert part-empty : +0 CHAN_WIN_ID=3 CHANNEL :#ch_test0
+insert part-empty : + CHAN_WIN_ID=3 CHANNEL :#ch_test0
> /part
log 3 $ not in that channel
# check /join without argument joins channel previously joined in same window
> /join
-insert join-empty 1: +0 CHANNEL :#ch_test0
+insert join-empty 1: + CHAN_WIN_ID=3 CHANNEL :#ch_test0
# check cannot /join channel already joined, neither from its window nor from elsewhere
-> /join
-log 3 $ already in that channel
-> /join #ch_test0
-log 3 $ already in that channel
+insert join-already-in : + LOG_WIN_ID=3 TARGET :
+insert join-already-in : + LOG_WIN_ID=3 TARGET :#ch_test0
> /window 2
-> /join #ch_test0
-log 2 $ already in that channel
+insert join-already-in : + LOG_WIN_ID=2 TARGET :#ch_test0
# check join to different channel name initiates new window, even if there's already a window for a channel that's been /parted
> /window 3
-insert part-empty : +0 CHAN_WIN_ID=3 CHANNEL :#ch_test0
-insert join-empty :-1 +0 CHANNEL :#ch_test1
-log 4 $ residents: foo
-
-# check /join to channel with one other user, and @ rather than = in 353 message
-insert join-channel-0 :-3 +0 CHANNEL :#ch_test0
-insert servermsglogged : +0 MSG ::foo.bar.baz 353 foo @ #ch_test0 :foo bar
-insert join-channel-0 -1: +1 CHANNEL :#ch_test0
-insert user-set-to :2 +1 USER_ID=1 USERNICK :bar
-insert join-channel-1 : +0 CHANNEL=#ch_test0 RESIDENT_IDS :[1], [me]
-log 3 $ residents: bar, foo
+insert part-empty : + CHAN_WIN_ID=3 CHANNEL :#ch_test0
+insert join-empty : + CHAN_WIN_ID=4 CHANNEL :#ch_test1
-# check /part from channel with other user
-insert part : +0 CHANNEL=#ch_test0 CHAN_WIN_ID=3 USERIDS_CLEAR :set to: [1]
+# check 353 also understood if using @ rather than =
+insert join-empty : + CHAN_WIN_ID=3 CHANNEL=#ch_test0 = :@
+insert part-empty : + CHAN_WIN_ID=3 CHANNEL :#ch_test0
+
+# check /join to, and part from, channel with one other user
+insert join-channel-0 : + CHANNEL=#ch_test0 RESIDENT_NAMES :foo bar
+insert user-set-to :2 + USER_ID=1 USERNICK :bar
+insert join-channel-1 : + CHANNEL=#ch_test0 RESIDENT_IDS :[1], [me]
+log 3 $ residents: bar, foo
+insert part : + CHANNEL=#ch_test0 CHAN_WIN_ID=3 USERIDS_CLEAR :set to: [1]
log 1 $ users:1 cleared
# check /join into channel with many other users, with multi-line 353
-insert join-channel-0 : +0 CHANNEL=#ch_test0 RESIDENT_NAMES :foo baz oof
-insert user-set-to :2 +1 USER_ID=2 USERNICK :baz
-insert user-set-to :2 +1 USER_ID=3 USERNICK :oof
-insert servermsglogged : +0 MSG ::foo.bar.baz 353 foo = #ch_test0 :rab zab
-insert user-set-to :2 +1 USER_ID=4 USERNICK :rab
-insert user-set-to :2 +1 USER_ID=5 USERNICK :zab
-insert join-channel-1 : +0 CHANNEL=#ch_test0 RESIDENT_IDS :[2], [3], [4], [5], [me]
+insert join-channel-0 : + CHANNEL=#ch_test0 RESIDENT_NAMES :foo baz oof
+insert user-set-to :2 + USER_ID=2 USERNICK :baz
+insert user-set-to :2 + USER_ID=3 USERNICK :oof
+insert servermsglogged : + MSG ::foo.bar.baz 353 foo = #ch_test0 :rab zab
+insert user-set-to :2 + USER_ID=4 USERNICK :rab
+insert user-set-to :2 + USER_ID=5 USERNICK :zab
+insert join-channel-1 : + CHANNEL=#ch_test0 RESIDENT_IDS :[2], [3], [4], [5], [me]
log 3 $ residents: baz, oof, rab, zab, foo
# check /join into channel with topic set
> /window 4
-insert part-empty : +0 CHAN_WIN_ID=4 CHANNEL :#ch_test1
-insert join-channel-0 :4 +0 CHANNEL :#ch_test1
-insert servermsglogged : +0 MSG ::foo.bar.baz 332 foo #ch_test1 :foo bar baz
+insert part-empty : + CHAN_WIN_ID=4 CHANNEL :#ch_test1
+insert join-channel-0-0 : + CHANNEL :#ch_test1
+insert servermsglogged : + MSG ::foo.bar.baz 332 foo #ch_test1 :foo bar baz
log 1 $ channels:#ch_test1:exits cleared
-insert servermsglogged : +0 MSG ::foo.bar.baz 333 foo #ch_test1 baz!~baz@OLD.baz.baz 1234567890
-insert topic-set-to : +1 baz.baz=OLD.baz.baz CHANNEL=#ch_test1 NEWTOPIC :foo bar baz
-insert servermsglogged : +0 MSG ::foo.bar.baz 353 foo = #ch_test1 :foo baz
-
-insert join-channel-1 : +0 CHANNEL=#ch_test1 RESIDENT_IDS :[2], [me]
+insert servermsglogged : + MSG ::foo.bar.baz 333 foo #ch_test1 baz!~baz@OLD.baz.baz 1234567890
+insert topic-set-to : + baz.baz=OLD.baz.baz CHANNEL=#ch_test1 NEWTOPIC :foo bar baz
+insert join-channel-0-1 :-1 + CHANNEL=#ch_test1 RESIDENT_NAMES :foo baz
+insert join-channel-1 : + CHANNEL=#ch_test1 RESIDENT_IDS :[2], [me]
log 4 $ residents: baz, foo
# check _observed_ topic change _does_ affect users database, and …
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo bar baz
-insert user-set-to 2: +1 USER_ID=2 USERNAME=~baz USERHOST :baz.baz
+insert servermsglogged : + MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo bar baz
+insert user-set-to 2: + USER_ID=2 USERNAME=~baz USERHOST :baz.baz
# … is echoed into channel window _if_ either content or setter change
-insert topic-set-to : +1 CHANNEL=#ch_test1 NEWTOPIC :foo bar baz
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo bar baz
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo foo baz
-insert topic-set-to : +1 CHANNEL=#ch_test1 NEWTOPIC :foo foo baz
+insert topic-set-to : + CHANNEL=#ch_test1 NEWTOPIC :foo bar baz
+insert servermsglogged : + MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo bar baz
+insert servermsglogged : + MSG ::baz!~baz@baz.baz TOPIC #ch_test1 :foo foo baz
+insert topic-set-to : + CHANNEL=#ch_test1 NEWTOPIC :foo foo baz
# check effects of other users' messages (PRIVMSG and NOTICE)
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz PRIVMSG #ch_test0 :msg_test3 msg_test4
+insert servermsglogged : + MSG ::baz!~baz@baz.baz PRIVMSG #ch_test0 :msg_test3 msg_test4
log 3 < [baz] msg_test3 msg_test4
-insert servermsglogged : +0 MSG ::oof!~oof@oof.oof NOTICE #ch_test0 :msg_test5 msg_test6
-insert user-set-to 2: +1 USER_ID=3 USERNAME=~oof USERHOST :oof.oof
+insert servermsglogged : + MSG ::oof!~oof@oof.oof NOTICE #ch_test0 :msg_test5 msg_test6
+insert user-set-to 2: + USER_ID=3 USERNAME=~oof USERHOST :oof.oof
log 3 < (oof) msg_test5 msg_test6
# check effect of server NOTICE to channel
-insert servermsglogged : +0 MSG ::*.?.net NOTICE #ch_test0 :msg_test6 msg_test7
+insert servermsglogged : + MSG ::*.?.net NOTICE #ch_test0 :msg_test6 msg_test7
log 3 < (*.?.net) msg_test6 msg_test7
-# check part of user visible in other channel
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz PART :#ch_test0
-log 1 $ channels:#ch_test0:exits:2 set to: [P]
-log 1 $ channels:#ch_test0:user_ids set to: [3], [4], [5], [me]
-log 3 $ baz!~baz@baz.baz parts
-log 1 $ channels:#ch_test0:exits:2 cleared
-
-# check part of user NOT visible in other channel
-insert servermsglogged : +0 MSG ::oof!~oof@oof.oof PART :#ch_test0
-log 1 $ channels:#ch_test0:exits:3 set to: [P]
-log 1 $ channels:#ch_test0:user_ids set to: [4], [5], [me]
-log 3 $ oof!~oof@oof.oof parts
-log 1 $ channels:#ch_test0:exits:3 cleared
+# check part of user visible, and of user NOT visible in other channel
+insert part-other : + NICK=baz USER_ID=2 REMAINING_IDS :[3], [4], [5], [me]
+insert part-other : + NICK=oof USER_ID=3 REMAINING_IDS :[4], [5], [me]
log 1 $ users:3 cleared
# check other-user part with exit message
-insert servermsglogged : +0 MSG ::zab!~zab@zab.zab PART #ch_test0 :goodbye world
-insert user-set-to 2: +1 USER_ID=5 USERNAME=~zab USERHOST :zab.zab
-log 1 $ channels:#ch_test0:exits:5 set to: [Pgoodbye world]
-log 1 $ channels:#ch_test0:user_ids set to: [4], [me]
-log 3 $ zab!~zab@zab.zab parts: goodbye world
-log 1 $ channels:#ch_test0:exits:5 cleared
+insert servermsglogged : + MSG ::zab!~zab@zab.zab PART #ch_test0 :goodbye
+insert user-set-to 2: + USER_ID=5 USERNAME=~zab USERHOST :zab.zab
+insert parts-core : + CHAN_WIN_ID=3 CHANNEL=#ch_test0 USER_ID=5 NICK=zab exitPREFIX=:§ exitMSG=goodbye USERIDS_CLEAR=set§to:§[4],§[me] § :
log 1 $ users:5 cleared
# check re-join of user kept visible in other channel
-insert servermsglogged : +0 MSG ::baz!~baz@baz.baz JOIN :#ch_test0
+insert servermsglogged : + MSG ::baz!~baz@baz.baz JOIN :#ch_test0
log 1 $ channels:#ch_test0:user_ids set to: [2], [4], [me]
log 3 $ baz!~baz@baz.baz joins
# check re-join of user NOT kept visible in other channel
-insert servermsglogged : +0 MSG ::oof!~oof@oof.oof JOIN :#ch_test0
-insert user-set-to : +1 USER_ID=6 USERNICK=oof USERNAME=~oof USERHOST :oof.oof
+insert servermsglogged : + MSG ::oof!~oof@oof.oof JOIN :#ch_test0
+insert user-set-to : + USER_ID=6 USERNICK=oof USERNAME=~oof USERHOST :oof.oof
log 1 $ channels:#ch_test0:user_ids set to: [2], [4], [6], [me]
log 3 $ oof!~oof@oof.oof joins
# check renaming of user communicated into all windows of channels they're in – be it others, or oneself
-insert rename : +0 USER_ID=2 NUH=baz!~baz@baz.baz NEWNICK :bazbaz
-insert cmd-nick : +0 NUH=foo!~baz@baz.bar.foo USER_ID=me NEWNICK :myself
+insert rename : + USER_ID=2 NUH=baz!~baz@baz.baz NEWNICK :bazbaz
+insert rename : + USER_ID=2 NUH=bazbaz!~baz@baz.baz NEWNICK :baz
+insert cmd-nick : + NUH=foo!~baz@baz.bar.foo USER_ID=me NEWNICK :myself
# reverting to foo to easen fragment re-use later on
-insert cmd-nick : +0 NUH=myself!~baz@baz.bar.foo USER_ID=me NEWNICK :foo
+insert cmd-nick : + NUH=myself!~baz@baz.bar.foo USER_ID=me NEWNICK :foo
# check QUIT affecting user in all their channels, removing them from DB
-insert servermsglogged : +0 MSG ::bazbaz!~baz@baz.baz QUIT :Client Quit
+insert servermsglogged : + MSG ::baz!~baz@baz.baz QUIT :Client Quit
log 1 $ users:2:exit_msg set to: [QClient Quit]
-log , $ bazbaz!~baz@baz.baz quits: Client Quit
-log 1 $ channels:#ch_test0:exits:2 set to: [QClient Quit]
-log 1 $ channels:#ch_test0:user_ids set to: [4], [6], [me]
-log 3 $ bazbaz!~baz@baz.baz quits: Client Quit
-log 1 $ channels:#ch_test0:exits:2 cleared
-log 1 $ channels:#ch_test1:exits:2 set to: [QClient Quit]
-log 1 $ channels:#ch_test1:user_ids set to: [me]
-log 4 $ bazbaz!~baz@baz.baz quits: Client Quit
-log 1 $ channels:#ch_test1:exits:2 cleared
+log , $ baz!~baz@baz.baz quits: Client Quit
+insert quit : + CHAN_WIN_ID=3 CHANNEL=#ch_test0 USER_ID=2 NICK=baz REMAINING_IDS :[4], [6], [me]
+insert quit : + CHAN_WIN_ID=4 CHANNEL=#ch_test1 USER_ID=2 NICK=baz REMAINING_IDS :[me]
log 1 $ users:2 cleared
# check effects of own QUIT while present in one channel
-insert part-empty : +0 CHAN_WIN_ID=4 CHANNEL :#ch_test1
+insert part-empty : + CHAN_WIN_ID=4 CHANNEL :#ch_test1
insert cmd-disconnect-0
-log 1 $ channels:#ch_test0:exits:me set to: [QClient Quit]
-log 1 $ channels:#ch_test0:user_ids set to: [4], [6]
-log 3 $ foo!~baz@baz.bar.foo quits: Client Quit
-log 1 $ channels:#ch_test0:exits:me cleared
-insert cmd-disconnect-1 :-1 +0
-insert disconnect1 : +1 WIN_IDS :2,3,4
+insert quit : + CHAN_WIN_ID=3 CHANNEL=#ch_test0 USER_ID=me NICK=foo foo@foo.foo=baz@baz.bar.foo REMAINING_IDS :[4], [6]
+insert cmd-disconnect-1 :-1
+insert disconnect1 : + WIN_IDS :2,3,4
# check /reconnect calling auto-rejoin on the one channel inhabited on previous leaving
insert reconnect
# check same mechanism holding on externally triggered disconnect
servermsg 0 FAKE_IRC_CONN_ABORT_EXCEPTION
-insert disconnect0 :-1 +1 EXIT_MSG :broken: FAKE_IRC_CONN_ABORT_EXCEPTION
-insert disconnect1 : +1 WIN_IDS :2,3,4
-insert retry-in : +1 ? :1
+insert disconnect0 :-1 + EXIT_MSG :broken: FAKE_IRC_CONN_ABORT_EXCEPTION
+insert disconnect1 : + WIN_IDS :2,3,4
+insert retry-in : + ? :1
insert reconnect