| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 101 | #print "rv=$rv\n"; | ||||||||||
| 102 | 1 | ▶ | print "failed scalar $five != $four\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 111 | #print "rv=$rv\n"; | ||||||||||
| 112 | 1 | ▶ | print "failed scalar $t432 != ",$five,"\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 119 | #print "rv = $rv\n"; | ||||||||||
| 120 | 1 | ▶ | print "failed scalar $t532 != $t432\nnot " | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | if $rv; | ||||||||||
| 122 | 1 | &ok; | |||||||||