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. --Geoff