mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-30 04:09:28 +02:00
IdeDebugger: fix parsing ".." range for arrays (after ^ deref)
(cherry picked from commit b38ca94a08
)
This commit is contained in:
parent
ee6a3fed0c
commit
c3a1844be1
@ -289,9 +289,16 @@ begin
|
|||||||
if InString then
|
if InString then
|
||||||
Continue;
|
Continue;
|
||||||
|
|
||||||
if p^ in ['@', '^', '.', '+', '-', '*', '/', '(', ',', '=', '<', '>', '#', '$', '%', '&', '!'] then
|
if p^ in ['@', '.', '+', '-', '*', '/', '(', ',', '=', '<', '>', '#', '$', '%', '&', '!'] then
|
||||||
MaybeBeforeRange := False // after operator. A [1..5] would be a set of byte
|
MaybeBeforeRange := False // after operator. A [1..5] would be a set of byte
|
||||||
|
|
||||||
|
else
|
||||||
|
if (p - s >= 2) and
|
||||||
|
(p[-2] in [#1..#32]) and (p[-1] in ['i', 'I']) and
|
||||||
|
(p^ in ['n', 'N']) and (p[1] in [#1..#32])
|
||||||
|
then
|
||||||
|
MaybeBeforeRange := False // after IN operator. A [1..5] would be a set of byte
|
||||||
|
|
||||||
else
|
else
|
||||||
if p^ in ['a'..'z', 'A'..'Z', '_', ')', ']'] then
|
if p^ in ['a'..'z', 'A'..'Z', '_', ')', ']'] then
|
||||||
MaybeBeforeRange := True // after identifier, or after ")" or "]"
|
MaybeBeforeRange := True // after identifier, or after ")" or "]"
|
||||||
|
@ -154,6 +154,11 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="TestXmlOpts"/>
|
<UnitName Value="TestXmlOpts"/>
|
||||||
</Unit>
|
</Unit>
|
||||||
|
<Unit>
|
||||||
|
<Filename Value="testvarious.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="TestVarious"/>
|
||||||
|
</Unit>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
@ -3,7 +3,7 @@ program TestIdeDebugger;
|
|||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Interfaces, Forms, GuiTestRunner, TestWatchResult, TestXmlOpts;
|
Interfaces, Forms, GuiTestRunner, TestWatchResult, TestXmlOpts, TestVarious;
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
54
ide/packages/idedebugger/test/testvarious.pas
Normal file
54
ide/packages/idedebugger/test/testvarious.pas
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
unit TestVarious;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
{$INLINE off}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, fpcunit, testutils, testregistry,
|
||||||
|
IdeDebuggerUtils,
|
||||||
|
LazLogger;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TTestIdeDebuggerVarious }
|
||||||
|
|
||||||
|
TTestIdeDebuggerVarious = class(TTestCase)
|
||||||
|
published
|
||||||
|
procedure TestExpressionForArrayElement;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
{ TTestIdeDebuggerVarious }
|
||||||
|
|
||||||
|
procedure TTestIdeDebuggerVarious.TestExpressionForArrayElement;
|
||||||
|
begin
|
||||||
|
AssertEquals('a', 'a[11]', GetExpressionForArrayElement('a', 11));
|
||||||
|
AssertEquals('(a)', '(a)[11]', GetExpressionForArrayElement('(a)', 11));
|
||||||
|
AssertEquals('a[2]', 'a[2][11]', GetExpressionForArrayElement('a[2]', 11));
|
||||||
|
|
||||||
|
AssertEquals('(a * [1..22]) * b[3..33]', '(a * [1..22]) * b[11]', GetExpressionForArrayElement('(a * [1..22]) * b[3..33]', 11));
|
||||||
|
AssertEquals('(a in [1..22]) * b[3..33]', '(a in [1..22]) * b[11]', GetExpressionForArrayElement('(a in [1..22]) * b[3..33]', 11));
|
||||||
|
AssertEquals('( an [1..22]) * b[3..33]', '( an [11]) * b[3..33]', GetExpressionForArrayElement('( an [1..22]) * b[3..33]', 11));
|
||||||
|
|
||||||
|
AssertEquals('a[2..22]', 'a[11]', GetExpressionForArrayElement('a[2..22]', 11));
|
||||||
|
AssertEquals('a[-2..22]', 'a[11]', GetExpressionForArrayElement('a[-2..22]', 11));
|
||||||
|
AssertEquals('a[-22..-2]', 'a[-11]', GetExpressionForArrayElement('a[-22..-2]', -11));
|
||||||
|
AssertEquals('a[2..22][3..33]', 'a[11][3..33]', GetExpressionForArrayElement('a[2..22][3..33]', 11));
|
||||||
|
AssertEquals('a[2..22]*b[3..33]', 'a[11]*b[3..33]', GetExpressionForArrayElement('a[2..22]*b[3..33]', 11));
|
||||||
|
AssertEquals('Foo(a[2..22])', 'Foo(a[11])', GetExpressionForArrayElement('Foo(a[2..22])', 11));
|
||||||
|
|
||||||
|
AssertEquals('PCellProps((TFpList((StringGrid1.FGrid.FCellArr.FCols.FList)^[0..3]).FList)^[0..3])^',
|
||||||
|
'PCellProps((TFpList((StringGrid1.FGrid.FCellArr.FCols.FList)^[2]).FList)^[0..3])^',
|
||||||
|
GetExpressionForArrayElement('PCellProps((TFpList((StringGrid1.FGrid.FCellArr.FCols.FList)^[0..3]).FList)^[0..3])^', 2)
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
RegisterTest(TTestIdeDebuggerVarious);
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user