Lite/t/over_equal.t

filter: Statementstmt 100% 50 / 50 Branchbran 50.0% 17 / 34 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 80.4% 70 / 87 CC 1 SCAR 0.0
CC
1
Cov
80%
BEGIN
1.0
BEGIN
1.0
ok
1.0
CRAP 1.0
« Lite/t/over-qq.t ↑ Summary Lite/t/v4-last.t »
1  
2 #use diagnostics;
3 1 ▶use NetAddr::IP::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 $| = 1;
6  
7 1 print "1..14\n";
8  
9 1 my $test = 1;
10 14 ▶sub ok() {
Subroutine ok: called CC=1 SCAR=0.0
11 14 print 'ok ',$test++,"\n";
12 }
13  
14 1 my $four = new NetAddr::IP::Lite('0.0.0.4'); # same as 0.0.0.4/32
15 1 my $four120 = new NetAddr::IP::Lite('::4/120'); # same as 0.0.0.4/24
16  
17 1 my $t432 = '0.0.0.4/32';
18 1 my $t4120 = '0:0:0:0:0:0:0:4/120';
19  
20 1 my $five = new NetAddr::IP::Lite('0.0.0.5');
21 1 my $t532 = '0.0.0.5/32';
22  
23  
24 # 1
25 ## test '""' overload
26 1 my $txt = sprintf ("%s",$four120);
27  
28 1 ▶print "got: $txt, exp: $t4120\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txt eq $t4120 0 1 1
29 unless $txt eq $t4120;
30 1 &ok;
31  
32 # 2
33 ## test '""' again
34 1 $txt = sprintf ("%s",$four);
35  
36 1 ▶print "got: $txt, exp: $t432\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $txt eq $t432 0 1 1
37 unless $txt eq $t432;
38 1 &ok;
39  
40 # 3
41 ## test 'eq' to scalar
42 1 ▶print 'failed ',$four," eq $t432\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $four eq $t432 0 1 1
43 unless $four eq $t432;
44 1 &ok;
45  
46 # 4
47 ## test scalar 'eq' to
48 1 ▶print "failed $t432 eq ",$four,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $t432 eq $four 0 1 1
49 unless $t432 eq $four;
50 1 &ok;
51  
52 # 5
53 ## test 'eq' to self
54 1 ▶print 'failed ',$four,' eq ', $four,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $four eq $four 0 1 1
55 unless $four eq $four;
56 1 &ok;
57  
58 # 6
59 ## test 'eq' cidr !=
60 1 ▶print 'failed ',$four,' should not eq ',$four120,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
if $four eq $four120 0 1 1
61 if $four eq $four120;
62 1 &ok;
63  
64 # 7
65 ## test '==' not for scalars
66 1 ▶print "failed scalar $t432 should not == ",$four,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
if $t432 == $four 0 1 1
67 if $t432 == $four;
68 1 &ok;
69  
70 # 8
71 ## test '== not for scalar, reversed args
72 1 ▶print 'failed scalar ',$four," should not == $t432\nnot "
Branch: 1 branch
BranchTrueFalseTotal
if $four == $t432 0 1 1
73 if $four == $t432;
74 1 &ok;
75  
76 # ==========================================
77 #
78 # test "ne" and "!="
79 #
80 # 9
81 ## test 'ne' to scalar
82 1 ▶print 'failed ',$four120," ne $t432\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $four120 ne $t432 0 1 1
83 unless $four120 ne $t432;
84 1 &ok;
85  
86 # 10
87 ## test scalar 'ne' to
88 1 ▶print "failed $t432 ne ",$four120,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $t432 ne $four120 0 1 1
89 unless $t432 ne $four120;
90 1 &ok;
91  
92 # 11
93 ## test 'ne' to cidr
94 1 ▶print 'failed ',$four,' ne ', $four120,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $four ne $four120 0 1 1
95 unless $four ne $four120;
96 1 &ok;
97  
98 # 12
99 ## test '!=' not for scalar, reversed args
100 1 ▶$rv = $five != $four ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$five != $four ? : 1 0 1
101 #print "rv=$rv\n";
102 1 ▶print "failed scalar $five != $four\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv 0 1 1
103 unless $rv;
104 1 &ok;
105  
106 # unblessed scalars not welcome
107 1 undef local $^W;
108 # 13
109 ## test '!=' not for scalars
110 1 ▶my $rv = $t432 != $five ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$t432 != $five ? : 1 0 1
111 #print "rv=$rv\n";
112 1 ▶print "failed scalar $t432 != ",$five,"\nnot "
Branch: 1 branch
BranchTrueFalseTotal
unless $rv 0 1 1
113 unless $rv;
114 1 &ok;
115  
116 # 14
117 # since both of these are string scalars, the != should fail
118 1 ▶$rv = $t532 != $t432 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$t532 != $t432 ? : 0 1 1
119 #print "rv = $rv\n";
120 1 ▶print "failed scalar $t532 != $t432\nnot "
Branch: 1 branch
BranchTrueFalseTotal
if $rv 0 1 1
121 if $rv;
122 1 &ok;
« Lite/t/over-qq.t ↑ Summary Lite/t/v4-last.t »