Geoffrey Young wrote:
ok t_cmp ( undef, &get_undef, "Retrieve undef from subroutine" );
# expected: undef # received: Retrieve undef from subroutine not ok 1
get_undef is slurping up the text as an argument. call it as get_undef() instead (nobody really uses the & calling format anymore anyway :)
oh, wait, that's not it. anyway, I've seen this myself before which is why I was quick to (wrongly) answer :) personally, I usually just
my $val = get_undef;
t_cmp(1, $val, "text");
the problem seems to be with return
$ perl -MApache::TestUtil -e 't_cmp(1,foo(),"text"); sub foo { return }' # expected: 1 # received: text
$ perl -MApache::TestUtil -e 't_cmp(1,foo(),"text"); sub foo { return undef }' # testing : text # expected: 1 # received: undef
and 'return undef' is considered bad form, since it doesn't do the right thing in a list context, so most people won't do it. but it's the list context that's tripping us up, as @_ that t_cmp() receives is now only 2 arguments wide:
$ perl -e '@a = (1, foo(), "text"); print scalar @a; sub foo { return }' 2
I don't think there is anything we can do about it, so just use the workaround above.
Yes, I'm aware of this problem too. I sometimes use a different workaround. Using Geoff's one liner:
perl -MApache::TestUtil -e 't_cmp(1,scalar(foo()),"text"); sub foo { return }'
perl -le '@a = (1, scalar foo(), "text"); print scalar @a; sub foo { return }' 3
Also William can you check what Test::More does to deal with this problem? Eventually we may drop t_cmp completely and move into Test::More, whose API is much reacher and you better use it from the very beginning instead of Apache::TestUtil, if you can afford requiring Test::More.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com