Skip to content

Commit 5939e74

Browse files
committed
test difference betwen nonassoc and nonlistassoc
also, check precedence level of structural infix
1 parent b00a4f4 commit 5939e74

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

S03-operators/precedence.t

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ proper separation of the two levels.
1313
1414
=end pod
1515

16-
plan 65;
16+
plan 69;
1717

1818

1919
# terms
@@ -81,10 +81,10 @@ ok(?(!(1 & 2 ^ 4) != 3), "blah blah blah");
8181

8282
{ # test that | and ^ are on the same level but parsefail
8383
throws-like 'my Mu $a = (1 | 2 ^ 3)',
84-
X::Syntax::NonAssociative,
84+
X::Syntax::NonListAssociative,
8585
'| and ^ may not associate';
8686
throws-like 'my Mu $a = (1 ^ 2 | 3)',
87-
X::Syntax::NonAssociative,
87+
X::Syntax::NonListAssociative,
8888
'^ and | may not associate';
8989
};
9090

@@ -99,6 +99,18 @@ ok(?(!(1 & 2 ^ 4) != 3), "blah blah blah");
9999

100100
ok(0 < 2 <=> 1 < 2, "0 < 2 <=> 1 < 2 means 0 < 1 < 2");
101101

102+
# structural infix
103+
104+
is (1 | 3 <=> 2).gist, 'any(Less, More)', '<=> binds looser than |';
105+
is (1 == 3 <=> 2).gist, 'True', '<=> binds tighter than ==';
106+
throws-like '1 .. 2 .. 3',
107+
X::Syntax::NonAssociative,
108+
'identical .. is not associative';
109+
throws-like '1 <=> 2 leg 3',
110+
X::Syntax::NonAssociative,
111+
'<=> and leg are not associative';
112+
113+
102114
# chaining
103115

104116
is((0 != 1 && "foo"), "foo", "!= binds tighter than &&");
@@ -164,10 +176,10 @@ is(((not 1,42)[1]), 42, "not is tighter than comma");
164176
# RT #77848
165177
{
166178
throws-like '4 X+> 1...2',
167-
X::Syntax::NonAssociative,
179+
X::Syntax::NonListAssociative,
168180
'X+> must not associate with ...';
169181
throws-like q['08:12:23'.split(':') Z* 60 X** reverse ^3],
170-
X::Syntax::NonAssociative,
182+
X::Syntax::NonListAssociative,
171183
'Z* and X** are non associative';
172184
}
173185

@@ -221,7 +233,7 @@ ok ((1 => 2 => 3).value ~~ Pair), '=> is right-assoc (2)';
221233
# L<S03/Operator precedence/only works between identical operators>
222234

223235
throws-like '1, 2 Z 3, 4 X 5, 6',
224-
X::Syntax::NonAssociative,
236+
X::Syntax::NonListAssociative,
225237
'list associativity only works between identical operators';
226238

227239
#?niecza skip 'assigning to readonly value'

0 commit comments

Comments
 (0)