in reply to Concatenate strings before Test::More::ok
What you may want to do is something like this (I'm using your original module):
Output:use warnings; use strict; use Test::More 'no_plan'; BEGIN { use_ok('Mysimple_mod', qw (external) ) }; my $mod = 'Mysimple_mod'; ok ( defined( &external ), "#2 external is defined"); ok ( defined( &Mysimple_mod::internal ), "#3 internal is defined"); ok ( defined( &Mysimple_mod::bogus ), "#4 bogus subroutine"); ok ( defined( &{"${mod}::bogus"} ), "#5 bogus subroutine"); my @softies = qw(internal); # my @softies = qw(internal bogus); for my $softy (@softies) { my $func = "${mod}::$softy"; no strict 'refs'; ok( $func->(3) == 9, qq{invoke soft ref'd func $func( 9)} ); ok( $func->(3) == 10, qq{invoke soft ref'd func $func(10)} ); }
See what happens if you add bogus to the @softies array.C:\@Work\Perl\monks\gctaylor1>perl test_soft_refs_1.pl ok 1 - use Mysimple_mod; ok 2 - \#2 external is defined ok 3 - \#3 internal is defined not ok 4 - \#4 bogus subroutine # Failed test (test_soft_refs_1.pl at line 77) not ok 5 - \#5 bogus subroutine # Failed test (test_soft_refs_1.pl at line 78) ok 6 - invoke soft ref'd func Mysimple_mod::internal( 9) not ok 7 - invoke soft ref'd func Mysimple_mod::internal(10) # Failed test (test_soft_refs_1.pl at line 87) 1..7 # Looks like you failed 3 tests of 7.
|
|---|