Validate funcs and globals rather than using can() to avoid unintended side effects

This commit is contained in:
Eric A. Miller
2018-04-26 20:48:02 -04:00
parent 7221797826
commit 8d1681dbfc

View File

@@ -122,13 +122,19 @@ sub globals : Tests(2) {
can_ok($test->{info}, 'globals'); can_ok($test->{info}, 'globals');
subtest 'Globals can() subtest' => sub { subtest 'Globals validate subtest' => sub {
my $test_globals = $test->{info}->globals; my $test_globals = $test->{info}->globals;
if (scalar keys %$test_globals) { if (scalar keys %$test_globals) {
foreach my $key (sort (keys %$test_globals)) { foreach my $key (sort (keys %$test_globals)) {
can_ok($test->{info}, $key);
# Note: was going to use can_ok() as test method, but can() will insert
# AUTOLOAD methods such as the Globals and Funcs into the symbol table.
# This causes conflicts with the library inheritance scheme and
# manifests itself seemingly random test failures
ok($test->{info}->_validate_autoload_method($key),
qq('$key' validates));
} }
} }
else { else {
@@ -142,13 +148,19 @@ sub funcs : Tests(2) {
can_ok($test->{info}, 'funcs'); can_ok($test->{info}, 'funcs');
subtest 'Funcs can() subtest' => sub { subtest 'Funcs validate subtest' => sub {
my $test_funcs = $test->{info}->funcs; my $test_funcs = $test->{info}->funcs;
if (scalar keys %$test_funcs) { if (scalar keys %$test_funcs) {
foreach my $key (sort (keys %$test_funcs)) { foreach my $key (sort (keys %$test_funcs)) {
can_ok($test->{info}, $key);
# Note: was going to use can_ok() as test method, but can() will insert
# AUTOLOAD methods such as the Globals and Funcs into the symbol table.
# This causes conflicts with the library inheritance scheme and
# manifests itself seemingly random test failures
ok($test->{info}->_validate_autoload_method($key),
qq('$key' validates));
} }
} }
else { else {