File: testnestedfoldslist.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (142 lines) | stat: -rw-r--r-- 3,519 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
unit TestNestedFoldsList;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, TestBase, testregistry, SynEdit, SynHighlighterPas,
  SynEditHighlighterFoldBase, LazLoggerBase, TestHighlightPas;

type

  { TTestNestedFoldsList }

  TTestNestedFoldsList = class(TTestBaseHighlighterPas)
  private
    FNestList: TLazSynEditNestedFoldsList;
  protected
    procedure TearDown; override;
    procedure ReCreateEdit; reintroduce;
    procedure ReCreateList;
    function TestText1: TStringArray;
  published
    procedure Test1;
  end;


implementation

{ TTestNestedFoldsList }

procedure TTestNestedFoldsList.TearDown;
begin
  FreeAndNil(FNestList);
  inherited TearDown;
end;

procedure TTestNestedFoldsList.ReCreateEdit;
begin
  FreeAndNil(FNestList);
  inherited ReCreateEdit;
  ReCreateList;
end;

procedure TTestNestedFoldsList.ReCreateList;
begin
  FreeAndNil(FNestList);
  FNestList := TLazSynEditNestedFoldsList.Create(SynEdit.TextBuffer, PasHighLighter);
  FNestList.ResetFilter;
  FNestList.FoldGroup := 0;
  FNestList.FoldFlags := [sfbIncludeDisabled];
  FNestList.IncludeOpeningOnLine := True;
end;

function TTestNestedFoldsList.TestText1: TStringArray;
begin
  SetLength(Result, 26);
  Result[0]  := 'program Foo;';
  Result[1]  := 'begin';
  Result[2]  := '  while FTheDebugger.DebugProcessRunning and not(FTheDebugger.State in [dsError, dsDestroying]) do';
  Result[3]  := '  begin';
  Result[4]  := '';
  Result[5]  := '    {$IFDEF DBG_ASYNC_WAIT}';
  Result[6]  := '    if GotPrompt > 0 then begin';
  Result[7]  := '    {$ENDIF}';
  Result[8]  := '';
  Result[9]  := '      if (S = ''(gdb) '') or';
  Result[10] := '         ( (S = '') and FDidKillNow )';
  Result[11] := '      then';
  Result[12] := '        {$IFDEF DBG_ASYNC_WAIT}';
  Result[13] := '        begin';
  Result[14] := '          if (not FGotStopped) and (not FDidKillNow) and (GotPrompt = 0) then';
  Result[15] := '            GotPrompt := 1';
  Result[16] := '          else';
  Result[17] := '            break;';
  Result[18] := '        end;';
  Result[19] := '        {$ELSE}';
  Result[20] := '        Break;';
  Result[21] := '        {$ENDIF}';
  Result[22] := '';
  Result[23] := '    end;';
  Result[24] := '  end;';
  Result[25] := '';
end;

procedure TTestNestedFoldsList.Test1;
var
  start, start2, nth, grp, i, j: Integer;
begin
  // this test currently only checks that no ASSERT is triggered

//  PushBaseName('');
  for start := 0 to 24 do begin
  for start2 := 0 to 3  do begin
  for nth := 1 to 4 do begin
  for grp := 0 to 1 do begin
    ReCreateEdit;
    //PopPushBaseName('Text 1 -- [cfbtBeginEnd..cfbtNone], [], 0');
    SetLines(TestText1);
    EnableFolds([cfbtBeginEnd..cfbtNone], []);
    FNestList.FoldGroup := grp;

    for i := start to 25 do begin
      FNestList.Line := i;
      if i mod nth = 0 then
        for j := start2*2 to FNestList.Count - 1 do begin
          FNestList.HLNode[j];
          FNestList.NodeEndLine[j]
        end;
    end;

    ReCreateEdit;
    //PopPushBaseName('Text 1 -- [cfbtBeginEnd..cfbtNone], [], 0');
    SetLines(TestText1);
    EnableFolds([cfbtBeginEnd..cfbtNone], []);
    FNestList.FoldGroup := grp;
    FNestList.FoldFlags := [];

    for i := start to 25 do begin
      FNestList.Line := i;
      if i mod nth = 0 then
        for j := start2*2 to FNestList.Count - 1 do begin
          FNestList.HLNode[j];
          FNestList.NodeEndLine[j]
        end;
    end;


  end;
  end;
  end;
  end;

end;


initialization

  RegisterTest(TTestNestedFoldsList);

end.