Skip to content

Commit

Permalink
Add tests for RT #124323
Browse files Browse the repository at this point in the history
  • Loading branch information
usev6 committed Apr 17, 2015
1 parent aee9f9e commit 1790997
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion S03-operators/ternary.t
Expand Up @@ -4,7 +4,7 @@ use Test;

#Ternary operator ?? !!

plan 25;
plan 27;
#L<S03/Changes to Perl 5 operators/"The ? : conditional operator becomes ?? !!">

my $str1 = "aaa";
Expand Down Expand Up @@ -82,6 +82,18 @@ throws_like { EVAL '1 ?? 3:foo :: 2' },
operator => ":foo",
'adverbed literal in second part of ternary';

# RT #124323
{
my @x = ^10;
my @y = 2..3;
throws_like { EVAL 'my @z = @y ?? @x[@y] :v !! @x' },
X::Syntax::ConditionalOperator::PrecedenceTooLoose,
operator => ':v',
'precedence of adverb in second part of ternary is too loose';
is @y ?? (@x[@y] :v) !! @x, "2 3",
'adverb in second part of ternary used with parenthesis works';
}

throws_like { EVAL '1 ?? (3:foo) !! 2' },
X::Syntax::Adverb,
'parenthesized adverbed literal in second part of ternary';
Expand Down

0 comments on commit 1790997

Please sign in to comment.