Branch Coverage

blib/lib/LJ/Simple.pm
Criterion Covered Total %
branch 128 676 18.9


line true false branch
289 0 0 if (not defined $direct) { }
290 0 0 unless (defined $data)
298 0 0 if $direct
495 1 42 unless defined $v
499 31 3 if exists $opts{$_}
503 1 9 if (exists $opts{'html'} and not $opts{'html'} =~ /^[01]$/)
507 3 6 if (exists $opts{'protect'} and $opts{'protect'} eq 'groups')
508 1 2 unless (exists $opts{'groups'})
512 1 1 if (ref $opts{'groups'} ne 'ARRAY')
518 1 6 if (exists $opts{'tags'} and ref $opts{'tags'} ne 'ARRAY')
522 1 5 if (exists $opts{'results'} and ref $opts{'results'} ne 'HASH')
528 5 0 if $LJ::Simple::TestStopQuickPost
534 0 0 unless defined $lj
537 0 0 unless $lj->NewEntry(\%Event)
538 0 0 unless $lj->SetEntry(\%Event, $opts{'entry'})
539 0 0 if exists $opts{'subject'}
541 0 0 if exists $opts{'mood'}
543 0 0 if exists $opts{'music'}
545 0 0 if exists $opts{'html'}
547 0 0 if exists $opts{'protect'}
550 0 0 if exists $opts{'tags'}
554 0 0 if defined $item_id
555 0 0 if (exists $opts{'results'})
754 2 9 if ($#_ != 0)
763 0 9 if (not exists $$hr{'user'} or $$hr{'user'} eq '' or not exists $$hr{'pass'} or $$hr{'pass'} eq '')
773 1 8 if (not defined $LJ::Simple::UTF) { }
8 0 elsif ($LJ::Simple::UTF) { }
775 1 0 if (not $@) { }
784 8 0 if (not $@) { }
792 9 0 if (not $@) { }
798 1 8 unless defined $LJ::Simple::challenge
800 0 0 if (defined $LJ::Simple::challenge and $LJ::Simple::challenge)
806 1 8 if (exists $$hr{'site'} and defined $$hr{'site'} and $$hr{'site'} ne '') { }
808 0 1 if ($$hr{'site'} =~ /\s*(.*?):([0-9]+)\s*$/)
822 0 9 if (exists $$hr{'proxy'} and defined $$hr{'proxy'} and $$hr{'proxy'} ne '') { }
8 1 elsif (not exists $$hr{'proxy'}) { }
824 0 0 if ($$hr{'proxy'} =~ /\s*(.*?):([0-9]+)\s*$/)
837 14 2 unless exists $ENV{$env}
838 0 2 unless $ENV{$env} =~ m[^(?:http://)([^:/]+)(?::([0-9]+)){0,1}]o
843 1 1 unless defined $$self{'proxy'}{'port'}
852 4 5 if (exists $$hr{'fast'} and $$hr{'fast'} == 1)
859 1 4 if (exists $$hr{'moods'} and $$hr{'moods'} == 0)
863 1 4 if (exists $$hr{'pics'} and $$hr{'pics'} == 0)
868 5 0 unless $self->SendRequest('login', {'moods', $GetMoods, 'getpickws', $GetPics, 'getpickurls', $GetPics}, undef)
875 0 0 if (exists $$self{'request'}{'lj'}{'fastserver'} and $$self{'request'}{'lj'}{'fastserver'} == 1)
899 0 0 if ($k eq 'message') { }
0 0 elsif ($k =~ /^mood_([0-9]+)_([a-z]+)/o) { }
0 0 elsif ($k =~ /^(pickw_count)/o) { }
0 0 elsif ($k eq 'defaultpicurl') { }
0 0 elsif ($k =~ /^(pickw[^_]*)_([0-9]+)/o) { }
0 0 elsif ($k =~ /^access_([0-9]+)/) { }
0 0 elsif ($k =~ /^frgrp_([0-9]+)_(.*)/) { }
905 0 0 unless (defined $$self{'moods'})
908 0 0 unless (exists $$self{'moods'}{$id})
911 0 0 if ($type eq 'id') { }
0 0 elsif ($type eq 'name') { }
919 0 0 unless (defined $$self{'pictures'})
926 0 0 unless (defined $$self{'pictures'})
929 0 0 unless (exists $$self{'pictures'}{$id})
932 0 0 if ($type eq 'pickwurl') { }
0 0 elsif ($type eq 'pickw') { }
940 0 0 unless (defined $$self{'access'})
948 0 0 unless (defined $$self{'groups'})
955 0 0 unless (exists $$self{'groups'}{'src'}{$id})
958 0 0 if ($type eq 'sortorder') { }
0 0 elsif ($type eq 'name') { }
972 0 0 unless (exists $$self{'groups'}{'name'}{$$v{'name'}})
984 0 0 if ($GetMoods)
1071 0 1 if (ref $hr ne 'HASH')
1075 1 0 unless (defined $$self{'moods'})
1110 1 0 unless defined $$self{'access'}
1135 1 0 unless defined $$self{'access'}
1181 0 1 if (ref $hr ne 'HASH')
1185 1 0 unless (defined $$self{'groups'})
1222 1 0 unless (defined $$self{'groups'})
1226 0 0 unless (exists $$self{'groups'}{'name'}{$grp})
1248 1 0 unless (defined $$self{'groups'})
1252 0 0 unless (exists $$self{'groups'}{'id'}{$id})
1299 1 0 unless (defined $$self{'pictures'})
1303 0 0 if (ref $hr ne 'HASH')
1333 0 0 unless (defined $$self{'defaultpicurl'})
1424 0 0 unless $self->SendRequest('getusertags', \%Event, \%Resp)
1427 0 0 unless $name =~ /tag_([0-9]+)_(.*)/o
1429 0 0 unless exists $Tags{$id}
1437 0 0 exists $$src{$_} ? :
1508 0 0 unless $self->SendRequest('friendof', \%Event, \%Resp)
1512 0 0 unless $k =~ /^friendof_([0-9]+)_(.*)/
1514 0 0 unless (exists $Friends{$id})
1632 0 0 unless $self->SendRequest('getfriends', \%Event, \%Resp)
1636 0 0 unless $k =~ /^friend_([0-9]+)_(.*)/
1638 0 0 unless (exists $Friends{$id})
1652 0 0 if ($type eq 'birthday') { }
1653 0 0 unless $v =~ /([0-9]+)-([0-9]{2})-([0-9]{2})/o
1655 0 0 if ($tm[5] > 0)
1657 0 0 unless (defined $Friends{$id}{'dob'})
1664 0 0 unless (defined $Friends{$id}{'birthday'})
1672 0 0 if (defined $$self{'groups'})
1675 0 0 unless defined $$id{'groupmask'}
1678 0 0 if (($$id{'groupmask'} & $bit) == $bit)
1719 0 0 if ($#groups > -1)
1720 0 0 unless (defined $$self{'groups'})
1727 0 0 unless (exists $$self{'groups'}{'name'}{$g})
1735 0 0 if (exists $$self{'checkfriends'}) { }
1738 0 0 if ($currtime < $$self{'checkfriends'}{'interval'})
1745 0 0 unless $self->SendRequest('checkfriends', \%Event, \%Resp)
1788 0 0 if (ref $hr ne 'HASH')
1796 0 0 if (defined $journal and $journal ne '')
1799 0 0 unless $self->SendRequest('getdaycounts', \%Event, \%Resp)
1802 0 0 unless $k =~ /([0-9]+)-([0-9]+)-([0-9]+)/o
1803 0 0 if $v == 0
1805 0 0 unless (defined $timet)
1809 0 0 if (exists $$hr{$timet}) { }
1878 0 0 if (ref $hr ne 'HASH')
1886 0 0 unless $self->SendRequest('getfriendgroups', \%Event, \%Resp)
1889 0 0 unless $k =~ /^frgrp_([0-9]+)_(.*)$/o
1891 0 0 unless (exists $$hr{$id})
1897 0 0 if $name eq 'sortorder'
1930 0 0 if (ref $event ne 'HASH')
1992 0 0 if (ref $event ne 'HASH')
1996 0 0 unless defined $timet
1997 0 0 if ($timet < 0)
2038 0 0 if (ref $event ne 'HASH')
2042 0 0 unless (defined $mood)
2047 0 0 if (not $mood =~ /\s/ and defined $$self{'mood_map'})
2049 0 0 if (exists $$self{'mood_map'}{$lc_mood})
2077 0 0 if (ref $event ne 'HASH')
2081 0 0 unless (defined $journal)
2085 0 0 if (defined $$self{'access'} and not exists $$self{'access'}{$journal})
2116 0 0 if (ref $event ne 'HASH')
2120 0 0 unless defined $subject
2121 0 0 if (length $subject > 255)
2126 0 0 if ($subject =~ /[\r\n]/)
2173 0 0 if (ref $event ne 'HASH')
2177 0 0 if (not defined $entry[0] or $#entry == -1) { }
2224 0 0 if (ref $event ne 'HASH')
2228 0 0 if (not defined $$event{'event'}) { }
2229 0 0 if (not defined $entry[0] or $#entry == -1) { }
2235 0 0 if (not defined $entry[0] or $#entry == -1)
2295 0 0 if (ref $event ne 'HASH')
2299 0 0 unless (defined $type)
2303 0 0 if ($type eq 'public') { }
0 0 elsif ($type eq 'friends') { }
0 0 elsif ($type eq 'groups') { }
0 0 elsif ($type eq 'private') { }
2336 0 0 if (ref $event ne 'HASH')
2341 0 0 if exists $$event{'allowmask'}
2366 0 0 if (ref $event ne 'HASH')
2394 0 1 if (ref $event ne 'HASH')
2398 1 0 unless (defined $$self{'groups'})
2402 0 0 if ($#grps == -1)
2410 0 0 unless (defined $g)
2414 0 0 unless (exists $$self{'groups'}{'name'}{$g})
2441 0 0 if (ref $event ne 'HASH')
2446 0 0 if exists $$event{'allowmask'}
2458 0 0 if (ref $event ne 'HASH')
2462 0 0 unless (defined $prop)
2466 0 0 unless (defined $caller)
2470 0 0 unless (defined $type)
2474 0 0 unless (defined $data)
2479 0 0 if ($type eq 'bool') { }
0 0 elsif ($type eq 'char') { }
0 0 elsif ($type eq 'num') { }
2480 0 0 if ($data == 1 or $data == 0) { }
2489 0 0 unless ($data =~ /^[0-9]+$/o)
2498 0 0 unless (defined $nd)
2577 0 0 if ($mood =~ /[\r\n]/)
2610 0 0 if (defined $$self{'moods'})
2611 0 0 unless (exists $$self{'moods'}{$data})
2709 0 0 if (defined $$self{'pictures'})
2712 0 0 if ($$_{'name'} eq $data)
2717 0 0 unless ($match)
2815 0 0 if (ref $event ne 'HASH')
2819 0 0 unless (exists $$event{'__new_entry'})
2825 0 0 if /^__/
2827 0 0 unless (defined $$event{'event'})
2833 0 0 unless defined $$event{$_}
2837 0 0 unless $self->SendRequest('postevent', $event, \%Resp)
2839 0 0 unless (exists $Resp{'itemid'})
2843 0 0 unless (exists $Resp{'anum'})
2891 0 0 if (ref $event ne 'HASH')
2895 0 0 unless (exists $$event{'__itemid'})
2902 0 0 if /^__/
2904 0 0 unless (defined $$event{'event'})
2910 0 0 unless defined $$event{$_}
2933 0 0 unless (defined $item_id)
2937 0 0 unless ($item_id =~ /^[0-9]+$/)
3059 0 0 unless (defined $timet)
3063 0 0 if ($LJ::Simple::debug)
3065 0 0 if (defined $timet) { }
3074 0 0 if (defined $timet)
3075 0 0 if ($timet =~ /^[0-9]+$/) { }
3077 0 0 if ($#tm == -1)
3086 0 0 unless $self->SendRequest('syncitems', \%Event, \%Resp)
3094 0 0 if ($key =~ /sync_([0-9]+)_(.*)$/o) { }
0 0 elsif ($key eq 'sync_total') { }
0 0 elsif ($key eq 'sync_count') { }
3096 0 0 unless exists $Mh{$id}
3097 0 0 if ($name eq 'item') { }
0 0 elsif ($name eq 'action') { }
0 0 elsif ($name eq 'time') { }
3105 0 0 unless ($val =~ /([0-9]+)-([0-9]+)-([0-9]+)\s([0-9]+):([0-9]+):([0-9]+)/io)
3110 0 0 unless (defined $Mh{$id}{'time_t'})
3114 0 0 if ($Mh{$id}{'time_t'} > $latest)
3132 0 0 if ($sync_count != $sync_total)
3134 0 0 unless defined $num
3322 0 0 if (ref $hr ne 'HASH')
3326 0 0 unless (defined $type)
3333 0 0 if (defined $journal)
3337 0 0 if ($ctype eq 'day') { }
0 0 elsif ($ctype eq 'lastn') { }
0 0 elsif ($ctype eq 'one') { }
0 0 elsif ($ctype eq 'sync') { }
3338 0 0 if ($#opts < 0)
3343 0 0 unless ($timestamp =~ /^[0-9]+$/)
3348 0 0 if ($#tm == -1)
3357 0 0 if ($#opts < 1)
3363 0 0 if (defined $num) { }
3364 0 0 unless ($num =~ /^[0-9]{1,2}$/)
3368 0 0 if ($num > 50)
3376 0 0 if (defined $beforedate)
3377 0 0 unless ($beforedate =~ /^[0-9]+$/)
3382 0 0 if ($#tm == -1)
3389 0 0 if ($#opts < 0)
3394 0 0 unless ($item_id =~ /^-*[0-9]+$/)
3398 0 0 if ($item_id < -1)
3405 0 0 if ($#opts < 0)
3410 0 0 unless ($lastsync =~ /^[0-9]+$/)
3415 0 0 if ($#tm == -1)
3425 0 0 unless $self->SendRequest('getevents', \%Event, \%Resp)
3431 0 0 if ($k =~ /^events_([0-9]+)_(.*)$/) { }
0 0 elsif ($k =~ /^prop_([0-9]+)_(.*)$/) { }
3436 0 0 if (defined $hash)
3437 0 0 unless exists $$hash{$num}
3453 0 0 if defined $journal
3454 0 0 if exists $$ehr{'subject'}
3455 0 0 if exists $$ehr{'allowmask'}
3456 0 0 if exists $$ehr{'security'}
3457 0 0 if ($$ehr{'eventtime'} =~ /([0-9]+)-([0-9]+)-([0-9]+)\s([0-9]+):([0-9]+):([0-9]+)/o) { }
3464 0 0 unless (defined $timet)
3476 0 0 unless (exists $$hr{$$phr{'itemid'}})
3482 0 0 unless (exists $$nhr{$k})
3524 0 0 if (ref $event ne 'HASH')
3528 0 0 unless (exists $$event{'__timet'})
3557 0 0 if (ref $event ne 'HASH')
3561 0 0 unless (exists $$event{'__itemid'})
3565 0 0 unless (exists $$event{'__anum'})
3569 0 0 unless (exists $$event{'__htmlid'})
3598 0 0 if (ref $event ne 'HASH')
3602 0 0 unless (exists $$event{'__htmlid'})
3632 0 0 if (ref $event ne 'HASH')
3636 0 0 unless (exists $$event{'subject'})
3663 0 0 if (ref $event ne 'HASH')
3667 0 0 unless (exists $$event{'event'})
3721 0 0 if (ref $event ne 'HASH')
3725 0 0 if (not exists $$event{'security'} or $$event{'security'} eq '')
3728 0 0 if ($$event{'security'} eq 'private')
3731 0 0 if ($$event{'security'} ne 'usemask')
3735 0 0 if (($$event{'allowmask'} & 1) == 1)
3742 0 0 if (($$event{'allowmask'} & $bit) == $bit)
3756 0 0 if (ref $event ne 'HASH')
3761 0 0 unless (exists $$event{$key})
3762 0 0 if ($type eq 'bool')
3998 0 30 unless defined $key
3999 0 30 unless defined $val
4013 0 28 unless defined $val
4044 0 10 if (defined $sub and ref $sub ne 'CODE')
4050 0 10 if (ref $args ne 'HASH' and $mode ne 'getchallenge')
4054 0 10 if (defined $req_hash and ref $req_hash ne 'HASH')
4062 5 5 if ($mode ne 'getchallenge')
4067 5 0 if ($LJ::Simple::challenge)
4071 1 4 unless $self->SendRequest('getchallenge', undef, \%chall)
4072 0 4 if ($chall{'auth_scheme'} ne 'c0')
4098 4 0 if (exists $$self{'auth'}{'challenge'}{'hash'}) { }
4105 0 0 if (exists $$self{'auth'}{'hash'}) { }
4112 4 0 if ($LJ::Simple::UTF)
4117 0 9 if defined $sub
4118 4 5 if ($mode eq 'login') { }
0 5 elsif ($mode eq 'postevent' or $mode eq 'editevent' or $mode eq 'syncitems' or $mode eq 'getevents' or $mode eq 'getfriends' or $mode eq 'friendof' or $mode eq 'checkfriends' or $mode eq 'getdaycounts' or $mode eq 'getfriendgroups' or $mode eq 'getusertags') { }
5 0 elsif ($mode eq 'getchallenge') { }
4120 3 1 if (exists $$args{'moods'} and $$args{'moods'} == 1)
4123 3 1 if (exists $$args{'getpickws'} and $$args{'getpickws'} == 1)
4138 0 0 if (defined $args)
4141 0 0 unless (defined $k)
4145 0 0 unless (defined $v)
4161 0 9 if defined $sub
4169 0 9 if (defined $$self{'proxy'})
4183 0 9 if ($$self{'fastserver'})
4197 0 9 if defined $sub
4199 0 9 unless (defined $addr)
4208 0 9 if $LJ::Simple::protocol
4209 0 9 if ($LJ::Simple::raw_protocol)
4216 0 9 if defined $sub
4217 0 9 unless (connect SOCK, $sin)
4222 0 9 if $LJ::Simple::protocol
4223 0 9 if $LJ::Simple::raw_protocol
4227 0 9 if defined $sub
4236 0 72 unless (defined $nbytes)
4237 0 0 if ($! == 11 or $! == 4) { }
4239 0 0 if ($fail > 4)
4256 0 72 if defined $sub
4258 0 72 if $LJ::Simple::protocol
4259 0 72 if $LJ::Simple::raw_protocol
4263 0 9 if defined $sub
4272 0 18 if (defined $sub) { }
4275 0 0 if ($nfound != 1)
4276 0 0 if ($ttaken > $LJ::Simple::timeout)
4288 0 18 if ($nfound != 1)
4297 0 18 if (not defined $nbytes) { }
9 9 elsif ($nbytes == 0) { }
4301 0 0 if defined $sub
4307 0 9 if defined $sub
4310 0 9 if ($LJ::Simple::raw_protocol) { }
0 9 elsif ($LJ::Simple::protocol) { }
4324 0 9 if defined $sub
4327 0 9 unless (shutdown SOCK, 2)
4329 0 0 if defined $sub
4336 0 9 if defined $sub
4338 0 9 unless (defined $response)
4344 0 9 if (length $response == 0)
4346 0 0 if defined $sub
4353 0 9 unless (defined $http)
4355 0 0 if defined $sub
4358 0 9 unless (defined $body)
4360 0 0 if defined $sub
4372 1 8 if ($srv_code != 200)
4384 28 8 if ($body =~ /^([^\n]+)\n([^\n]*)\n(.*)$/so) { }
4395 4 4 if (not exists $$self{'request'}{'lj'}{'success'} or $$self{'request'}{'lj'}{'success'} ne 'OK')
4398 4 0 if (exists $$self{'request'}{'lj'}{'errmsg'})
4402 0 4 if defined $sub
4408 4 0 if (defined $req_hash)
4416 0 4 if defined $sub
4424 60 0 unless $LJ::Simple::debug
4443 0 0 if (ref $le eq 'HASH') { }
0 0 elsif (ref $le eq 'ARRAY') { }
4451 0 0 if (defined $lv) { }
4478 14 25 if (ref $v eq 'HASH') { }
0 25 elsif (ref $v eq 'ARRAY') { }
4485 24 1 if (defined $v) { }