* fix case of string with ranges as labels

+ add test

git-svn-id: trunk@38860 -
This commit is contained in:
svenbarth 2018-04-27 21:06:33 +00:00
parent 52e7678033
commit cfa373a8cf
3 changed files with 44 additions and 1 deletions

1
.gitattributes vendored
View File

@ -11521,6 +11521,7 @@ tests/tbs/tb0637.pp svneol=native#text/pascal
tests/tbs/tb0638.pp svneol=native#text/pascal
tests/tbs/tb0639.pp svneol=native#text/pascal
tests/tbs/tb0641.pp svneol=native#text/pascal
tests/tbs/tb0642.pp svneol=native#text/pascal
tests/tbs/tb205.pp svneol=native#text/plain
tests/tbs/tb610.pp svneol=native#text/pascal
tests/tbs/tb613.pp svneol=native#text/plain

View File

@ -723,7 +723,7 @@ implementation
newcheck:=@check;
labitem:=TLinkedListCaseLabelItem(lablist[j]).casenode;
newcheck^:=caddnode.create(equaln,left.getcopy,labitem^._low_str.getcopy);
if (labtree^._low_str.fullcompare(labtree^._high_str)<>0) then
if (labitem^._low_str.fullcompare(labitem^._high_str)<>0) then
begin
newcheck^.nodetype:=gten;
newcheck^:=caddnode.create(

42
tests/tbs/tb0642.pp Normal file
View File

@ -0,0 +1,42 @@
program tb0642;
{$mode objfpc}
{$h+}
type
TResult = (
resFirst,
resSecond,
resElse
);
function Test(const aStr: String): TResult;
begin
case aStr of
'Hello', 'Hello2': Exit(resFirst);
'a'..'z': Exit(resSecond);
else
Exit(resElse);
end;
end;
begin
if Test('Hello') <> resFirst then
Halt(1);
if Test('Hello2') <> resFirst then
Halt(2);
if Test('a') <> resSecond then
Halt(3);
if Test('z') <> resSecond then
Halt(4);
if Test('g') <> resSecond then
Halt(5);
if Test('alpha') <> resSecond then
Halt(6);
if Test('zeta') <> resElse then
Halt(7);
if Test('A') <> resElse then
Halt(8);
if Test('1') <> resElse then
Halt(9);
Writeln('ok');
end.