Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (23 sloc) 0.997 kb
use v6;
use Test;
=begin pod
The ? case definitely shouldn't be a syntax error. The next question is
what the correct boolean value is for a Pair; always-true is now assumed
for consistency with the "one-key hash" semantics.
=end pod
plan 6;
# See thread "Stringification, numification, and booleanification of pairs" on
# p6l started by Ingo Blechschmidt:
# L<"">
my $true_pair = 1 => 1;
my $false_pair = 1 => 0;
lives_ok { ?$true_pair }, 'Taking the boolean of a true pair should live';
lives_ok { ?$false_pair }, 'Taking the boolean of a false pair should live';
ok (try { ?$true_pair }), 'A pair with a true value is true';
ok (try { ?$false_pair }), 'A pair with a false value is also true';
is $true_pair ?? 1 !! 0, 1, 'Ternary on a true pair returns first option';
is $false_pair ?? 1 !! 0, 1, 'Ternary on a false pair returns first option too';
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.