in reply to Test::More::is_deeply apparently ignoring an argument?

Test::More::is_deeply is not ignoring an argument - that argument is never reaching it. That's because, in list (array) context (i.e., "wantarray" returns true), it is returning an empty list.

Try:

is_deeply(scalar $pdf->adjust_to_bounding_box($main_image), undef, "adjust_to_bounding_box returns on no second param" ); # test
And compare with:
my @got = $pdf->adjust_to_bounding_box($main); # @got should be an empty list.
Hope that helps.

Replies are listed 'Best First'.
Re^2: Test::More::is_deeply apparently ignoring an argument?
by merlyn (Sage) on Apr 03, 2005 at 15:21 UTC
    is_deeply(scalar $pdf->adjust_to_bounding_box($main_image), undef, "adjust_to_bounding_box returns on no second param" ); # test
    And that checks the scalar return value. If you want to check the list return value separately:
    is_deeply([$pdf->adjust_to_bounding_box($main_image)], [], "adjust_to_bounding_box returns on no second param (list con +text)" ); # test

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re^2: Test::More::is_deeply apparently ignoring an argument?
by Whitehawke (Pilgrim) on Apr 03, 2005 at 15:20 UTC

    Thank you, yes, that makes perfect sense. Ghu, I was tearing my hair out over this one; I knew that it had to be something simple and obvious, I just couldn't see it. Thanks again.

      Thank you, yes, that makes perfect sense. Ghu, I was tearing my hair out over this one; I knew that it had to be something simple and obvious, I just couldn't see it. Thanks again.

      If it makes you feel any better, I've been programming in Perl for about 9 years, and still, to this day, context-related bugs are the ones that trip me the most often, even though I learned about Perl's contexts from day 1 basically (I learned Perl by reading the 1st ed. of the Camel book, which covered contexts in depth). Just recently I read japhy's nice article on lists and arrays, and it made me feel like a newbie. It's ironic that a feature that is meant to make Perl more human-language-like trips me most often. I must have Vulcan blood or something.

      the lowliest monk