Skip to content

Commit 0d30dfa

Browse files
committed
Update tests
1 parent f38a8e8 commit 0d30dfa

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

source/compiler/tests/switch_expressions_syntax.meta

+6
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@ switch_expressions_syntax.pwn(49 -- 51) : error 040: duplicate "case" label (val
1212
switch_expressions_syntax.pwn(58 -- 59) : error 050: invalid range
1313
switch_expressions_syntax.pwn(66 -- 68) : error 040: duplicate "case" label (value 1)
1414
switch_expressions_syntax.pwn(66 -- 69) : error 040: duplicate "case" label (value 3)
15+
switch_expressions_syntax.pwn(77 -- 78) : warning 213: tag mismatch: expected tag "Tag", but found none ("_")
16+
switch_expressions_syntax.pwn(77 -- 80) : warning 213: tag mismatch: expected tag "Tag", but found none ("_")
17+
switch_expressions_syntax.pwn(77 -- 81) : warning 213: tag mismatch: expected tag "Tag", but found none ("_")
18+
switch_expressions_syntax.pwn(89 -- 91) : warning 213: tag mismatch: expected tag "Tag", but found none ("_")
19+
switch_expressions_syntax.pwn(89 -- 93) : warning 213: tag mismatch: expected tag "Tag", but found none ("_")
20+
switch_expressions_syntax.pwn(98 -- 100) : error 095: switch expression must contain a "default" case
1521
"""
1622
}

source/compiler/tests/switch_expressions_syntax.pwn

+32
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,35 @@ test_OverlayingRanges(value)
7171
);
7272
}
7373

74+
test_TagMismatchCase(value)
75+
{
76+
const Tag:TaggedConst = Tag:1;
77+
return switch (Tag:value;
78+
0: 0; // warning 213: tag mismatch: expected tag "Tag", but found none ("_")
79+
TaggedConst: 1;
80+
(Tag:2)..3: 2; // warning 213: tag mismatch: expected tag "Tag", but found none ("_")
81+
4..(Tag:5): 3; // warning 213: tag mismatch: expected tag "Tag", but found none ("_")
82+
(Tag:6)..(Tag:7): 4;
83+
_: 5
84+
);
85+
}
86+
87+
Tag:test_TagMismatchExpr(value)
88+
{
89+
return switch (value;
90+
0: Tag:0;
91+
1: 1; // warning 213: tag mismatch: expected tag "Tag", but found none ("_")
92+
_: 2 // warning 213: tag mismatch: expected tag "Tag", but found none ("_")
93+
);
94+
}
95+
96+
test_MissingDefault(value)
97+
{
98+
return switch (value;
99+
0: 0
100+
); // error 095: switch expression must contain a "default" case
101+
}
102+
74103
main()
75104
{
76105
test_NonConstCaseValue(0);
@@ -81,4 +110,7 @@ main()
81110
test_DuplicateCases(0);
82111
test_InvalidRange(0);
83112
test_OverlayingRanges(0);
113+
test_TagMismatchCase(0);
114+
test_TagMismatchExpr(0);
115+
test_MissingDefault(0);
84116
}

0 commit comments

Comments
 (0)