$TESTNUM += $count;
}
-sub okx {
+sub okx ($$) {
my ($ok, $comment) = @_;
return okn($TESTNUM++, $ok, $comment);
}
-sub okn {
+sub okn ($$$) {
my ($num, $ok, $comment) = @_;
defined $num or confess "No \$num supplied";
}
}
+sub useokx {
+ my ($module, $comment, @imports) = @_;
+
+ my $pack = caller;
+ eval <<EOS;
+package $pack;
+require $module;
+$module->import(\@imports);
+EOS
+ unless (okx(!$@, $comment)) {
+ my $msg = $@;
+ $msg =~ s/\n+$//;
+ $msg =~ s/\n/\n# /g;
+ print "# $msg\n";
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
sub matchn($$$$) {
my ($num, $str, $re, $comment) = @_;
- my $match = $str =~ $re;
+ my $match = defined($str) && $str =~ $re;
okn($num, $match, $comment);
unless ($match) {
- $str =~ s/\\/\\\\/g;
- $str =~ s/[^\x20-\x7E]/"\\x".sprintf("%02X", ord($1))/ge;
- print "# The string '$str'\n";
- print "# did not match '$re'\n";
+ print "# The value: ",_sv_str($str),"\n";
+ print "# did not match: qr/$re/\n";
}
return $match;
}