summaryrefslogtreecommitdiffstats
path: root/ksirc/test
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /ksirc/test
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksirc/test')
-rw-r--r--ksirc/test/nicklist.pl77
-rw-r--r--ksirc/test/tester.pl65
2 files changed, 142 insertions, 0 deletions
diff --git a/ksirc/test/nicklist.pl b/ksirc/test/nicklist.pl
new file mode 100644
index 00000000..948429eb
--- /dev/null
+++ b/ksirc/test/nicklist.pl
@@ -0,0 +1,77 @@
+sub rndchr {
+ my $string = "";
+ for(my $i = 0; $i < 8; $i++){
+ $string .= chr(int(rand(26)) + 97); # More or less the alpahbet
+ }
+ return $string;
+}
+
+srand(time());
+
+&timer(1, "&next_one", 1);
+
+$state = 0;
+$max_nicks = 100;
+$min_nicks = 5;
+$num_nicks = 0;
+%list_nicks = ();
+$repeat = 100000;
+$count = 0;
+
+@state = (\&join, \&part);
+
+$line = "~#test~*#* Users on #test:";
+for($i = 0; $i < $max_nicks; $i++){
+ my($mynick) = rndchr();
+ $list_nicks{$mynick} = 1;
+ $is_op = rand(100);
+ if($is_op > 50){
+ $mynick = "@" . $mynick;
+ }
+ $line .= " " . $mynick;
+ $num_nicks ++;
+}
+print "$line\n";
+
+sub next_one {
+ for(my($i) = 0; $i < 200; $i++){
+ $goto_state = int(rand($#state+1));
+ &{$state[$goto_state]};
+ }
+ if($count++ < $repeat){
+ &timer(1, "&next_one", 1);
+ }
+}
+
+sub join{
+ return if $num_nicks > $max_nicks;
+ my($mynick) = rndchr();
+ $list_nicks{$mynick} = 1;
+ print("~#test~*>* $mynick (blah\@blah) has joined channel #test\n");
+ $is_op = rand(100);
+ if($is_op > 75){
+ print "~#test~*+* Mode change \"+o $mynick\" on channel #test by ChanServ\n";
+ }
+ $is_voice = rand(100);
+ if($is_voice > 40){
+ print "~#test~*+* Mode change \"+v $mynick\" on channel #test by ChanServ\n";
+ }
+ $num_nicks ++;
+}
+
+sub part{
+ return if $num_nicks < $min_nicks;
+ AGAIN: {
+ my($times) = int(rand($num_nicks));
+ for($i = 0; $i<= $times; $i++){
+ ($mynick, $value) = each(%list_nicks);
+ }
+ return if $mynick eq '';
+ }
+ next AGAIN if $value != 1;
+ $list_nicks{$mynick} = 0;
+ print("~#test~*<* $mynick has left channel #test\n");
+
+ delete $list_nicks{$mynick};
+ $num_nicks --;
+}
diff --git a/ksirc/test/tester.pl b/ksirc/test/tester.pl
new file mode 100644
index 00000000..2815a3a1
--- /dev/null
+++ b/ksirc/test/tester.pl
@@ -0,0 +1,65 @@
+sub rndchr {
+ my $string = "";
+ for(my $i = 0; $i < 8; $i++){
+ $string .= chr(int(rand(26)) + 97); # More or less the alpahbet
+ }
+ return $string;
+}
+
+srand(time());
+
+&timer(1, "&next_one", 1);
+
+$state = 0;
+$max_win = 5;
+$win_open = 0;
+%wins = {};
+$repeat = 1000;
+$count = 0;
+
+
+sub next_one {
+ #
+ # State 0 is open window
+ #
+ if($state == 0){
+ $winnum = int(rand($max_win));
+ $winname = "#" . rndchr();
+ $wins{$winname} = 1;
+ print("~$winname~*>* You have joined channel $winname\n");
+ &docommand("/join $winname");
+ $state = 1;
+ $win_open ++;
+ }
+ #
+ # State 1 is print stuff to channel
+ #
+ elsif($state == 1){
+ while(($winname, $value) = each(%wins)){
+ &msg("$winname", rndchr());
+ &notice("$winname", rndchr());
+ }
+ $state = 2;
+ }
+ #
+ # State 2 is close window
+ #
+ elsif($state == 2){
+ if($win_open > $max_win){
+ $times = int(rand($win_open-1));
+ for($i = 0; $i<= $times; $i++){
+ ($winname, $value) = each(%wins);
+ }
+ print("~#test~ <boren> leaving $winname\n");
+ delete($wins{$winname});
+ print("~!all~*<* You have left channel $winname\n");
+ &docommand("/part $winname");
+ $win_open --;
+ }
+ $state = 0;
+ }
+
+ if($count++ < $repeat){
+ &timer(5, "&next_one", 1);
+ }
+} \ No newline at end of file