~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to test/codetoolstests/testcfgscript.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2014-02-22 10:25:57 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140222102557-ors9d31r84nz31jq
Tags: 1.2~rc2+dfsg-1
[ Abou Al Montacir ]
* New upstream pre-release.
  + Moved ideintf to components directory.
  + Added new package cairocanvas.
* Remove usage of depreciated parameters form of find. (Closes: Bug#724776)
* Bumped standard version to 3.9.5.
* Clean the way handling make files generation and removal.

[ Paul Gevers ]
* Remove nearly obsolete bzip compression for binary packages
  (See https://lists.debian.org/debian-devel/2014/01/msg00542.html)
* Update d/copyright for newly added dir in examples and components
* Update Vcs-* fields with new packaging location
* Update d/watch file to properly (Debian way) change upstreams versions
* Prevent 46MB of package size by sym linking duplicate files
* Patches
  - refresh to remove fuzz
  - add more Lintian found spelling errors
  - new patch to add shbang to two scripts in lazarus-src
* Drop lcl-# from Provides list of lcl-units-#
* Make lazarus-ide-qt4-# an arch all until it really contains stuff
* Make all metapackages arch all as the usecase for arch any doesn't
  seem to warrant the addition archive hit
* Fix permissions of non-scripts in lazarus-src-#

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{
2
2
 Test with:
3
3
     ./runtests --format=plain --suite=TTestCodetoolsCfgScript
4
 
     ./runtests --format=plain --suite=TestCfgScript
 
4
     ./runtests --format=plain --suite=TestCfgScriptBase
 
5
     ./runtests --format=plain --suite=TestCfgScriptLCL
5
6
}
6
7
unit TestCfgScript;
7
8
 
21
22
 
22
23
  TTestCodetoolsCfgScript = class(TTestCase)
23
24
  protected
24
 
    procedure TestResult(Script, ExpectedResult: string);
 
25
    procedure TestResult(Script, ExpectedResult: string; Vars: PCTCfgScriptVariables = nil);
25
26
    procedure TestSyntaxError(Script, ExpectedError: string);
26
27
  published
27
 
    procedure TestCfgScript;
 
28
    procedure TestCfgScriptBase;
 
29
    procedure TestCfgScriptLCL;
28
30
  end;
29
31
 
30
32
implementation
31
33
 
32
34
{ TTestCodetoolsCfgScript }
33
35
 
34
 
procedure TTestCodetoolsCfgScript.TestResult(Script, ExpectedResult: string);
 
36
procedure TTestCodetoolsCfgScript.TestResult(Script, ExpectedResult: string;
 
37
  Vars: PCTCfgScriptVariables);
35
38
var
36
39
  Engine: TCTConfigScriptEngine;
37
40
  ScriptResult: String;
40
43
  Engine:=TCTConfigScriptEngine.Create;
41
44
  try
42
45
    Engine.MaxErrorCount:=1;
 
46
    if Vars<>nil then
 
47
      Engine.Variables.Assign(Vars^);
43
48
    if not Engine.Execute(Script) then begin
44
49
      writeln('Script failed to run:');
45
50
      for i:=0 to Engine.ErrorCount-1 do
51
56
        Engine.Variables.WriteDebugReport('Variables');
52
57
      AssertEquals(Script,ExpectedResult,ScriptResult);
53
58
    end;
 
59
    if Vars<>nil then
 
60
      Vars^.Assign(Engine.Variables);
54
61
  finally
55
62
    Engine.Free;
56
63
  end;
75
82
  end;
76
83
end;
77
84
 
78
 
procedure TTestCodetoolsCfgScript.TestCfgScript;
 
85
procedure TTestCodetoolsCfgScript.TestCfgScriptBase;
79
86
begin
80
87
  TestResult('Result:=2;','2');
81
88
  TestResult('a:=2; b:=a; Result:=b;','2');
89
96
  TestSyntaxError('{invalid operator * }Result:=2*3;','expected ; of statement, but found *');
90
97
end;
91
98
 
 
99
procedure TTestCodetoolsCfgScript.TestCfgScriptLCL;
 
100
var
 
101
  Vars: TCTCfgScriptVariables;
 
102
begin
 
103
  Vars:=TCTCfgScriptVariables.Create;
 
104
  try
 
105
    Vars['TargetOS']:='wince';
 
106
    Vars['TargetCPU']:='arm';
 
107
    Vars['SrcOS2']:='';
 
108
    Vars['SrcOS']:='win';
 
109
    TestResult(
 
110
       '// LCLWidgetType'#10
 
111
      +'if undefined(LCLWidgetType) then begin'#10
 
112
      +'  //if GetIDEValue(''OS'')=TargetOS then begin'#10
 
113
      +'    // use the same widgettype as the IDE'#10
 
114
      +'    //LCLWidgetType := GetIDEValue(''LCLWidgetType'');'#10
 
115
      +'    //if LCLWidgetType=''nogui'' then'#10
 
116
      +'      //LCLWidgetType:='''';'#10
 
117
      +'  //end;'#10
 
118
      +'  if LCLWidgetType+''''='''' then begin'#10
 
119
      +'    if (TargetOS=''win32'') or (TargetOS=''win64'') then'#10
 
120
      +'      LCLWidgetType := ''win32'''#10
 
121
      +'    else if TargetOS=''wince'' then'#10
 
122
      +'      LCLWidgetType := ''wince'''#10
 
123
      +'    else if TargetOS=''darwin'' then'#10
 
124
      +'      LCLWidgetType := ''carbon'''#10
 
125
      +'    else'#10
 
126
      +'      LCLWidgetType:=''gtk2'';'#10
 
127
      +'  end;'#10
 
128
      +'end;'#10
 
129
      ,'',@Vars);
 
130
    //Vars.WriteDebugReport('LCL','  ');
 
131
    AssertEquals('LCLWidgetType','wince',Vars['LCLWidgetType']);
 
132
  finally
 
133
    Vars.Free;
 
134
  end;
 
135
end;
 
136
 
92
137
initialization
93
138
  AddToCodetoolsTestSuite(TTestCodetoolsCfgScript);
94
139