t/21-list.t
t/22-call.t
t/23-branch.t
+t/24-ops.t
t/90-boilerplate.t
t/91-pod.t
t/92-pod-coverage.t
}
my %ops;
+
$ops{$_} = 1 for scalops;
$ops{$_} = 0 for qw/stub nextstate/;
$ops{$_} = 1 for qw/padsv/;
$ops{$_} = 'list' for qw/padav/;
$ops{$_} = 'list' for qw/padhv rv2hv/;
$ops{$_} = 'list' for qw/padany flip match entereval readline/;
+
$ops{each} = { 0 => 0.5, 2 => 0.5 };
$ops{stat} = { 0 => 0.5, 13 => 0.5 };
+
$ops{caller} = sub { my @a = caller 0; scalar @a }->();
$ops{localtime} = do { my @a = localtime; scalar @a };
$ops{gmtime} = do { my @a = gmtime; scalar @a };
+$ops{$_} = { 0 => 0.5, 10 => 0.5 } for map "gpw$_", qw/nam uid ent/;
+$ops{$_} = { 0 => 0.5, 4 => 0.5 } for map "ggr$_", qw/nam gid ent/;
+$ops{$_} = 'list' for qw/ghbyname ghbyaddr ghostent/;
+$ops{$_} = { 0 => 0.5, 4 => 0.5 } for qw/gnbyname gnbyaddr gnetent/;
+$ops{$_} = { 0 => 0.5, 3 => 0.5 } for qw/gpbyname gpbynumber gprotoent/;
+$ops{$_} = { 0 => 0.5, 4 => 0.5 } for qw/gsbyname gsbyport gservent/;
+
sub enter {
my ($self, $cv) = @_;
use strict;
use warnings;
-use Test::More tests => 55;
+use Test::More tests => 50;
use Sub::Nary;
[ sub { return eval { do { eval { @a } } } }, 'list' ],
[ sub { eval 'return 1, 2' }, 'list' ],
-
- [ sub { return <$x> }, 'list' ],
-
- [ sub { return -f $0, -r $0 }, 2 ],
-
- [ sub { return caller 0 }, sub { my @a = caller 0; scalar @a }->() ],
- [ sub { return localtime }, do { my @a = localtime; scalar @a } ],
- [ sub { return gmtime }, do { my @a = gmtime; scalar @a } ],
);
my $i = 1;
for (@tests) {
my $r = $sn->nary($_->[0]);
- is_deeply($r, { $_->[1] => 1 }, 'return test ' . $i);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'return test ' . $i);
++$i;
}
use strict;
use warnings;
-use Test::More tests => 41;
+use Test::More tests => 36;
use Sub::Nary;
[ sub { eval { 1, do { eval { @a }, 2 } } }, 'list' ],
[ sub { eval '1, 2' }, 'list' ],
-
- [ sub { <$x> }, 'list' ],
-
- [ sub { -f $0, -r $0 }, 2 ],
-
- [ sub { caller 0 }, sub { my @a = caller 0; scalar @a }->() ],
- [ sub { localtime }, do { my @a = localtime; scalar @a } ],
- [ sub { gmtime }, do { my @a = gmtime; scalar @a } ],
);
my $i = 1;
for (@tests) {
my $r = $sn->nary($_->[0]);
- is_deeply($r, { $_->[1] => 1 }, 'list test ' . $i);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'list test ' . $i);
++$i;
}
my $i = 1;
for (@tests) {
my $r = $sn->nary($_->[0]);
- is_deeply($r, { $_->[1] => 1 }, 'call test ' . $i);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'call test ' . $i);
++$i;
}
use strict;
use warnings;
-use Test::More tests => 17;
+use Test::More tests => 14;
use Sub::Nary;
[ \&ret1234, { map { $_ => 0.25 } 1 .. 4 } ],
[ \&retinif, { 2 => 1 } ],
-
- [ sub { each %h }, { 0 => 0.5, 2 => 0.5 } ],
- [ sub { stat $0 }, { 0 => 0.5, 13 => 0.5 } ],
-
- [ sub { <*.*> }, { list => 1 / 3, 1 => 2 / 3 } ],
);
my $i = 1;
for (@tests) {
my $r = $sn->nary($_->[0]);
- is_deeply($r, $_->[1], 'branch test ' . $i);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'branch test ' . $i);
++$i;
}
--- /dev/null
+#!perl -T
+
+use strict;
+use warnings;
+
+use Test::More tests => 26;
+
+use Sub::Nary;
+
+my $sn = Sub::Nary->new();
+
+my ($x, %h);
+
+my @tests = (
+ [ sub { return <$x> }, 'list' ],
+
+ [ sub { -f $0, -r $0 }, 2 ],
+
+ [ sub { return caller 0 }, sub { my @a = caller 0; scalar @a }->() ],
+ [ sub { return localtime }, do { my @a = localtime; scalar @a } ],
+ [ sub { gmtime }, do { my @a = gmtime; scalar @a } ],
+
+ [ sub { each %h }, { 0 => 0.5, 2 => 0.5 } ],
+ [ sub { stat $0 }, { 0 => 0.5, 13 => 0.5 } ],
+
+ [ sub { do { getpwnam 'root' } }, { 0 => 0.5, 10 => 0.5 } ],
+ [ sub { 1; getpwuid '0' }, { 0 => 0.5, 10 => 0.5 } ],
+ [ sub { eval { return getpwent } }, { 0 => 0.5, 10 => 0.5 } ],
+ [ sub { do { getgrnam 'root' } }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { 1; getgrgid '0' }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { eval { return getgrent } }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { do { gethostbyname 'localhost' } }, 'list' ],
+ [ sub { 1; gethostbyaddr '', '' }, 'list' ],
+ [ sub { eval { return gethostent } }, 'list' ],
+ [ sub { do { getnetbyname '' } }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { 1; getnetbyaddr '', '' }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { eval { return getnetent } }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { do { getprotobyname 'tcp' } }, { 0 => 0.5, 3 => 0.5 } ],
+ [ sub { 1; getprotobynumber 6 }, { 0 => 0.5, 3 => 0.5 } ],
+ [ sub { eval { return getprotoent } }, { 0 => 0.5, 3 => 0.5 } ],
+ [ sub { do { getservbyname 'ssh', 'tcp' } }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { 1; getservbyport 22, 'tcp' }, { 0 => 0.5, 4 => 0.5 } ],
+ [ sub { eval { return getservent } }, { 0 => 0.5, 4 => 0.5 } ],
+
+ [ sub { <*.*> }, { list => 1 / 3, 1 => 2 / 3 } ],
+);
+
+my $i = 1;
+for (@tests) {
+ my $r = $sn->nary($_->[0]);
+ my $exp = ref $_->[1] ? $_->[1] : { $_->[1] => 1 };
+ is_deeply($r, $exp, 'ops test ' . $i);
+ ++$i;
+}