summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-02-10 11:14:23 +0000
committerNicholas Clark <nick@ccl4.org>2011-02-10 11:14:23 +0000
commitd47bdea7d8909b1e611d287c190124657af11c76 (patch)
tree86f1f65bf0507be6d290c17d36d13046230dc476 /t
parent17a3df4c6a07533e2c03c46fdd27e3ee295d61d0 (diff)
downloadperl-d47bdea7d8909b1e611d287c190124657af11c76.tar.gz
In test.pl, validate that require_ok() and use_ok() are called correctly.
It only provides a subset of the Test::More functionality, but could inadvertently be used in a way which is not compatible with Test::More, which is not the intent.
Diffstat (limited to 't')
-rw-r--r--t/test.pl17
1 files changed, 13 insertions, 4 deletions
diff --git a/t/test.pl b/t/test.pl
index f47bebbf0e..a66857699c 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -413,20 +413,29 @@ sub eq_hash {
!$fail;
}
+# We only provide a subset of the Test::More functionality.
sub require_ok ($) {
my ($require) = @_;
- eval <<REQUIRE_OK;
+ if ($require =~ tr/[A-Za-z0-9:.]//c) {
+ fail("Invalid character in \"$require\", passed to require_ok");
+ } else {
+ eval <<REQUIRE_OK;
require $require;
REQUIRE_OK
- _ok(!$@, _where(), "require $require");
+ is($@, '', _where(), "require $require");
+ }
}
sub use_ok ($) {
my ($use) = @_;
- eval <<USE_OK;
+ if ($use =~ tr/[A-Za-z0-9:.]//c) {
+ fail("Invalid character in \"$use\", passed to use");
+ } else {
+ eval <<USE_OK;
use $use;
USE_OK
- _ok(!$@, _where(), "use $use");
+ is($@, '', _where(), "use $use");
+ }
}
# runperl - Runs a separate perl interpreter.