develooper Front page | perl.perl5.porters | Postings from January 2018

[perl #132732] use if - behaviour does not match documentation

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
January 24, 2018 20:12
Subject:
[perl #132732] use if - behaviour does not match documentation
Message ID:
rt-4.0.24-22667-1516824724-1581.132732-15-0@perl.org
On Wed, 24 Jan 2018 18:16:40 GMT, grinnz@gmail.com wrote:
> On Wed, Jan 24, 2018 at 1:09 PM, James E Keenan via RT <
> perlbug-followup@perl.org> wrote:
> >
> >
> > As does 're'.  But there I get even stranger results.  Try this out (in
> > the patch):
> >
> > #####
> >     {
> >         eval "use if (0 > 1), q|re|, qw(is_regexp regexp_pattern);";
> >         ok (! re->can('is_regexp'), "Cannot is_regexp");
> >         ok (! re->can('regexp_pattern'), "Cannot regexp_pattern");
> >         ok (  re->can('is_regexp'), "Can    is_regexp");
> >         ok (  re->can('regexp_pattern'), "Can    regexp_pattern");
> >     }
> > #####
> > I get:
> > #####
> > not ok 11 - Cannot is_regexp
> > #   Failed test 'Cannot is_regexp'
> > #   at t/if.t line 73.
> > not ok 12 - Cannot regexp_pattern
> > #   Failed test 'Cannot regexp_pattern'
> > #   at t/if.t line 74.
> > ok 13 - Can    is_regexp
> > ok 14 - Can    regexp_pattern
> > #####
> >
> > Which I read as, "Whether or not the CONDITION evaluates to true or not,
> > the two functions are imported from package 're'."
> >
> >
> This does not look like it's testing imports; it's testing whether the
> is_regexp and regexp_pattern functions exist in re::, which is always true.
> 
> -Dan

Noted.  But please run the attached file.  To the best of my understanding of the 'if' documentation, the tests in the third block of the file should pass, i.e., they should catch exceptions and set $@.  They are not doing so?  What are we missing?

Thank you very much.

-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=132732

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About