| File: | t/01-Scalar-Util.t |
| Coverage: | 90.0% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | #!perl | ||||||
| 2 | |||||||
| 3 | 1 1 1 | 27943 3 81 | use strict; | ||||
| 4 | 1 1 1 | 4 1 42 | use warnings; | ||||
| 5 | |||||||
| 6 | 1 1 1 | 638 46549 10 | use Test::More tests => 19; | ||||
| 7 | |||||||
| 8 | 1 1 1 | 1590 4 82 | use Util::Underscore; | ||||
| 9 | |||||||
| 10 | 1 | 226727 | my %aliases = qw/ | ||||
| 11 | class blessed | ||||||
| 12 | ref_addr refaddr | ||||||
| 13 | ref_type reftype | ||||||
| 14 | ref_weaken weaken | ||||||
| 15 | ref_unweaken unweaken | ||||||
| 16 | ref_is_weak isweak | ||||||
| 17 | new_dual dualvar | ||||||
| 18 | is_dual isdual | ||||||
| 19 | is_vstring isvstring | ||||||
| 20 | is_numeric looks_like_number | ||||||
| 21 | is_open openhandle | ||||||
| 22 | is_readonly readonly | ||||||
| 23 | is_tainted tainted | ||||||
| 24 | /; | ||||||
| 25 | |||||||
| 26 | 1 | 8 | while (my ($k, $v) = each %aliases) { | ||||
| 27 | 1 1 1 | 5 2 2203 | no strict 'refs'; | ||||
| 28 | 13 13 13 | 41126 63 82 | ok \&{"_::$k"} == \&{"Scalar::Util::$v"}, "_::$k == Scalar::Util::$v"; | ||||
| 29 | } | ||||||
| 30 | |||||||
| 31 | # Test _::prototype | ||||||
| 32 | |||||||
| 33 | 0 | sub foo { die "unimplemented" } | |||||
| 34 | 1 0 | 662 0 | my $foo = sub { die "unimplemented" }; | ||||
| 35 | |||||||
| 36 | 1 | 7 | ok + (not defined _::prototype \&foo), 'sub prototype empty'; | ||||
| 37 | 1 | 701 | ok + (not defined _::prototype $foo), 'coderef prototype empty'; | ||||
| 38 | |||||||
| 39 | 1 | 663 | _::prototype \&foo, '$;\@@'; | ||||
| 40 | 1 | 5 | _::prototype $foo, '$;\@@'; | ||||
| 41 | |||||||
| 42 | 1 | 4 | is + (_::prototype \&foo), '$;\@@', 'sub prototype not empty'; | ||||
| 43 | 1 | 643 | is + (_::prototype $foo), '$;\@@', 'coderef prototype not empty'; | ||||
| 44 | |||||||
| 45 | 1 | 628 | _::prototype \&foo, undef; | ||||
| 46 | 1 | 3 | _::prototype $foo, undef; | ||||
| 47 | |||||||
| 48 | 1 | 8 | ok + (not defined _::prototype \&foo), 'sub prototype empty again'; | ||||
| 49 | 1 | 652 | ok + (not defined _::prototype $foo), 'coderef prototype empty again'; | ||||