PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/components/simpleideintf/examples/testh2pastool.lpr

http://github.com/graemeg/lazarus
Unknown | 99 lines | 85 code | 14 blank | 0 comment | 0 complexity | e54f538171b1ed8cb0be613ef9e78576 MD5 | raw file
 1{ Copyright (C) 2007 Mattias Gaertner
 2
 3  This source is free software; you can redistribute it and/or modify it under
 4  the terms of the GNU General Public License as published by the Free
 5  Software Foundation; either version 2 of the License, or (at your option)
 6  any later version.
 7
 8  This code is distributed in the hope that it will be useful, but WITHOUT ANY
 9  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
11  details.
12
13  A copy of the GNU General Public License is available on the World Wide Web
14  at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
15  to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16  MA 02111-1307, USA.
17  
18  Abstract:
19    Program to test single conversion tools.
20}
21
22program TestH2pasTool;
23
24{$mode objfpc}{$H+}
25
26uses
27  Interfaces, Classes, SysUtils, H2PasWizard, H2PasConvert, IDETextConverter,
28  SimpleIDEIntf, FileUtil;
29
30procedure TestTReplaceImplicitTypes(Converter: TIDETextConverter);
31var
32  Tool: TReplaceImplicitTypes;
33begin
34  Tool:=nil;
35  try
36    Tool:=TReplaceImplicitTypes.Create(nil);
37    Tool.Execute(Converter);
38  finally
39    Tool.Free;
40  end;
41end;
42
43procedure TestTFixArrayOfParameterType(Converter: TIDETextConverter);
44var
45  Tool: TFixArrayOfParameterType;
46begin
47  Tool:=nil;
48  try
49    Tool:=TFixArrayOfParameterType.Create(nil);
50    Tool.Execute(Converter);
51  finally
52    Tool.Free;
53  end;
54end;
55
56procedure TestTConvertFunctionTypesToPointers(Converter: TIDETextConverter);
57var
58  Tool: TConvertFunctionTypesToPointers;
59begin
60  Tool:=nil;
61  try
62    Tool:=TConvertFunctionTypesToPointers.Create(nil);
63    Tool.Execute(Converter);
64  finally
65    Tool.Free;
66  end;
67end;
68
69var
70  Filename: String;
71  Converter: TIDETextConverter;
72  TempFilename: String;
73begin
74  if ParamCount<1 then
75    raise Exception.Create('Missing filename');
76  Filename:=ParamStr(1);
77  if not FileExists(Filename) then
78    raise Exception.Create('File not found: "'+Filename+'"');
79  Converter:=nil;
80  try
81    // create a copy of the file, so that the test does no harm
82    TempFilename:=TextConverterToolClasses.GetTempFilename;
83    CopyFile(Filename,TempFilename,false);
84    // create the converter
85    Converter:=TIDETextConverter.Create(nil);
86    Converter.InitWithFilename(TempFilename);
87
88    // test
89    TestTReplaceImplicitTypes(Converter);
90    TestTFixArrayOfParameterType(Converter);
91    TestTConvertFunctionTypesToPointers(Converter);
92
93    // write result
94    writeln(Converter.Source);
95  finally
96    Converter.Free;
97  end;
98end.
99