Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more tests for adverbed things in ternaries
  • Loading branch information
FROGGS committed Apr 17, 2015
1 parent 4cc5663 commit 874a8ba
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion S03-operators/ternary.t
Expand Up @@ -4,7 +4,7 @@ use Test;

#Ternary operator ?? !!

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

my $str1 = "aaa";
Expand Down Expand Up @@ -77,6 +77,21 @@ throws_like { EVAL '1 ?? 3 :: 2' },
second-part => "::",
'conditional operator written as ?? :: throws typed exception';

throws_like { EVAL '1 ?? 3:foo :: 2' },
X::Syntax::ConditionalOperator::PrecedenceTooLoose,
operator => ":foo",
'adverbed literal in second part of ternary';

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

{
my $three = 3;
my $thing = 1 ?? $three:foo !! 2;
is $three, 3, 'variable and adverb in second part of ternary';
}

throws_like { EVAL '1 ?? 3 : 2' },
X::Syntax::ConditionalOperator::SecondPartInvalid,
second-part => ":",
Expand Down

0 comments on commit 874a8ba

Please sign in to comment.