Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary junctions of undefs in boolean context fails (21/37) #275

Closed
p6rt opened this issue Aug 24, 2008 · 7 comments
Closed

binary junctions of undefs in boolean context fails (21/37) #275

p6rt opened this issue Aug 24, 2008 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 24, 2008

Migrated from rt.perl.org#58302 (status was 'resolved')

Searchable as RT58302$

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

From @stifynsemons

I've attached a file, junctions.p6, which illustrates that binary junctions
treat "undef" as true, and not as false. My interpretation is that if you
have​:
if JUNCTION { THEN }

the JUNCTION simplifies down to a simple logical operation, as in Perl 5
(Though ^ doesn't mean quite the same thing with more than two operands).
Test cases 34-37 were an attempt to use them in other contexts, and it
seems that in an equality context, they work fine (or at least better).

Thus 1|undef is evaluated as true, as is 1&undef; but 0|undef is also
evaluated as true. On the other hand, 1^undef is true which contradicts the
theory, but 0^undef is true as well.

The output of the attached perl script is shown below.

ok 1
not ok 2
not ok 3
ok 4
not ok 5
not ok 6
not ok 7
ok 8
ok 9
not ok 10
ok 11
not ok 12
ok 13
ok 14
not ok 15
not ok 16
ok 17
ok 18
ok 19
ok 20
not ok 21
not ok 22
ok 23
ok 24
ok 25
not ok 26
ok 27
not ok 28
not ok 29
not ok 30
not ok 31
not ok 32
not ok 33
not ok 34
not ok 35
not ok 36
ok 37

System info​:
sully​:parrot stephensimmons$ perl6 -v
This is Rakudo Perl 6, revision 30440 built on parrot 0.7.0-devel
for darwin-thread-multi-2level.

Copyright 2006-2008, The Perl Foundation.

sully​:parrot stephensimmons$ uname -a
Darwin sully.local 9.4.0 Darwin Kernel Version 9.4.0​: Mon Jun 9 19​:30​:53
PDT 2008; root​:xnu-1228.5.20~1/RELEASE_I386 i386

Stephen Simmons

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

From @stifynsemons

junctions.p6

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

From @moritz

Stephen Simmons (via RT) wrote​:

I've attached a file, junctions.p6, which illustrates that binary junctions
treat "undef" as true, and not as false. My interpretation is that if you
have​:
if JUNCTION { THEN }

the JUNCTION simplifies down to a simple logical operation, as in Perl 5
(Though ^ doesn't mean quite the same thing with more than two operands).

Yes, that's my interpretation as well.

Test cases 34-37 were an attempt to use them in other contexts, and it
seems that in an equality context, they work fine (or at least better).

Thus 1|undef is evaluated as true, as is 1&undef; but 0|undef is also
evaluated as true. On the other hand, 1^undef is true which contradicts the
theory, but 0^undef is true as well.

The output of the attached perl script is shown below.

Thanks for the tests, I'll rewrite them in terms of Test.pm, and add
them to the test suite.

Tests 34 to 36 were a bit overcritical​:

(0|undef && say "not ok 34") || say "not ok 34";
(0&undef && say "not ok 35") || say "not ok 35";
(0^undef && say "not ok 36") || say "not ok 36";

but are easily corrected. The rest seem fine to me.

Cheers,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 25, 2008

From @stifynsemons

On Sun, Aug 24, 2008 at 1​:01 PM, Moritz Lenz via RT <
perl6-bugs-followup@​perl.org> wrote​:

Thanks for the tests, I'll rewrite them in terms of Test.pm, and add
them to the test suite.

I probably should learn how to do them the right way :-)

Tests 34 to 36 were a bit overcritical​:

(0|undef && say "not ok 34") || say "not ok 34";
(0&undef && say "not ok 35") || say "not ok 35";
(0^undef && say "not ok 36") || say "not ok 36";

but are easily corrected. The rest seem fine to me.

Oops. It appears with the 0.7.0 release that they still fail when
corrected.

Thanks,
Stephen Simmons

Cheers,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

From @bacek

This tests is now part of spectest suite.

Resolving ticket.

@p6rt
Copy link
Author

p6rt commented Nov 8, 2008

@chromatic - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Nov 8, 2008
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant