Spreadsheet-Edit
view release on metacpan or search on metacpan
t/autodetect.pl view on Meta::CPAN
sub test_autodetect($$;$) {
my ($rs_opthash, $expected_rx, $expected_err_re) = @_;
my $error_expected = defined($expected_err_re)
|| (!defined($expected_rx) && !$rs_opthash)
|| (!defined($expected_rx) && $rs_opthash && defined($rs_opthash->{title_rx}));
confess "missing expected_err_re"
if $error_expected && ref($expected_err_re) ne "Regexp";
my $have_opthash = defined($rs_opthash); # possibly {}
my $lno = (caller)[2];
my $msg = ivis 'Line $lno:';
$msg .= "Testing ".vis($rs_opthash) if $have_opthash; # {...}
$msg .= ivis ' Expecting $expected_rx' unless $error_expected;
my $got;
# %$rs_opthash is for read_spreadsheet() and may contain title_rx => ...
# but when calling title_rx() this is passed as a separate argument.
my %t_opts;
my $t_arg = 'auto';
if ($have_opthash) {
t/t_TestCommon.pm view on Meta::CPAN
my $i; map{ sprintf "%s%2d: %s\n", $prefix,++$i,$_ } (split /\n/,$_[0]);
}
# These wrappers add the caller's line number to the test description
# so they show when successful tests log their name.
# This is only visible with using "perl -Ilib t/xxx.t"
# not with 'prove -l' and so mostly pointless!
sub t_ok($;$) {
my ($isok, $test_label) = @_;
my $lno = (caller)[2];
$test_label = ($test_label//"") . " (line $lno)";
@_ = ( $isok, $test_label );
goto &Test2::V0::ok; # show caller's line number
}
sub ok_with_lineno($;$) { goto &t_ok };
sub t_is($$;$) {
my ($got, $exp, $test_label) = @_;
my $lno = (caller)[2];
$test_label = ($test_label//$exp//"undef") . " (line $lno)";
@_ = ( $got, $exp, $test_label );
goto &Test2::V0::is; # show caller's line number
}
sub is_with_lineno($$;$) { goto &t_is }
sub t_like($$;$) {
my ($got, $exp, $test_label) = @_;
my $lno = (caller)[2];
$test_label = ($test_label//$exp) . " (line $lno)";
@_ = ( $got, $exp, $test_label );
goto &Test2::V0::like; # show caller's line number
}
sub like_with_lineno($$;$) { goto &t_like }
sub _mycheck_end($$$) {
my ($errmsg, $test_label, $ok_only_if_failed) = @_;
return
if $ok_only_if_failed && !$errmsg;
my $lno = (caller)[2];
&Test2::V0::diag("**********\n${errmsg}***********\n") if $errmsg;
@_ = ( !$errmsg, $test_label );
goto &ok_with_lineno;
}
# Nicer alternative to mycheck() when 'expected' is a literal string, not regex
sub mycheckeq_literal($$$) {
my ($desc, $exp, $act) = @_;
#confess "'exp' is not plain string in mycheckeq_literal" if ref($exp); #not re!
$exp = show_white($exp); # stringifies undef
( run in 1.470 second using v1.01-cache-2.11-cpan-a3c8064c92c )