mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-11 05:38:00 -05:00
Add PStest
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@409 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
d1757e8512
commit
bd948c240a
220
Projects/PStest/project1.lpi
Normal file
220
Projects/PStest/project1.lpi
Normal file
@ -0,0 +1,220 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Title Value="TestApp"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="2"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="17">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="project1"/>
|
||||
<UsageCount Value="24"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="75" Y="10"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="24"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="..\..\Source\uPSRuntime.pas"/>
|
||||
<UnitName Value="uPSRuntime"/>
|
||||
<CursorPos X="26" Y="11271"/>
|
||||
<TopLine Value="11259"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\Source\uPSUtils.pas"/>
|
||||
<UnitName Value="uPSUtils"/>
|
||||
<CursorPos X="22" Y="325"/>
|
||||
<TopLine Value="309"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\..\..\FPC\FPCCheckout\rtl\objpas\classes\classesh.inc"/>
|
||||
<CursorPos X="3" Y="160"/>
|
||||
<TopLine Value="144"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\Source\uPSPreProcessor.pas"/>
|
||||
<UnitName Value="uPSPreProcessor"/>
|
||||
<CursorPos X="28" Y="5"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\..\Source\uPSR_controls.pas"/>
|
||||
<UnitName Value="uPSR_controls"/>
|
||||
<CursorPos X="1" Y="1"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\..\..\lazarus\lcl\controls.pp"/>
|
||||
<UnitName Value="Controls"/>
|
||||
<CursorPos X="37" Y="324"/>
|
||||
<TopLine Value="318"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\..\Source\testps.pas"/>
|
||||
<UnitName Value="TestPS"/>
|
||||
<CursorPos X="32" Y="86"/>
|
||||
<TopLine Value="83"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="testps.pas"/>
|
||||
<UnitName Value="TestPS"/>
|
||||
<CursorPos X="1" Y="119"/>
|
||||
<TopLine Value="88"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\uPSRuntime.pas"/>
|
||||
<UnitName Value="uPSRuntime"/>
|
||||
<CursorPos X="12" Y="2"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\uPSUtils.pas"/>
|
||||
<UnitName Value="uPSUtils"/>
|
||||
<CursorPos X="25" Y="11"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\uPSComponent.pas"/>
|
||||
<UnitName Value="uPSComponent"/>
|
||||
<CursorPos X="24" Y="16"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\upsutils.pas"/>
|
||||
<UnitName Value="uPSUtils"/>
|
||||
<CursorPos X="39" Y="15"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\PascalScript.inc"/>
|
||||
<CursorPos X="32" Y="48"/>
|
||||
<TopLine Value="30"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\PascalScriptFPC.inc"/>
|
||||
<CursorPos X="28" Y="15"/>
|
||||
<TopLine Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="..\..\..\..\Documents\pascalscript\Source\x86.inc"/>
|
||||
<CursorPos X="65" Y="115"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit16>
|
||||
</Units>
|
||||
<JumpHistory Count="7" HistoryIndex="6">
|
||||
<Position1>
|
||||
<Filename Value="testps.pas"/>
|
||||
<Caret Line="20" Column="44" TopLine="1"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="testps.pas"/>
|
||||
<Caret Line="13" Column="18" TopLine="5"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="159" Column="65" TopLine="129"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="154" Column="31" TopLine="145"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="10" Column="75" TopLine="1"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="testps.pas"/>
|
||||
<Caret Line="108" Column="76" TopLine="84"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="testps.pas"/>
|
||||
<Caret Line="119" Column="1" TopLine="88"/>
|
||||
</Position7>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)\"/>
|
||||
<OtherUnitFiles Value="..\..\Units\PascalScript\"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<CStyleOperator Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
22
Projects/PStest/project1.lpr
Normal file
22
Projects/PStest/project1.lpr
Normal file
@ -0,0 +1,22 @@
|
||||
program project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ you can add units after this }, Unit1, LResources;
|
||||
|
||||
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
|
||||
|
||||
begin
|
||||
Application.Title:='TestApp';
|
||||
{$I project1.lrs}
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
5237
Projects/PStest/project1.lrs
Normal file
5237
Projects/PStest/project1.lrs
Normal file
File diff suppressed because it is too large
Load Diff
17
Projects/PStest/project1.manifest
Normal file
17
Projects/PStest/project1.manifest
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="CompanyName.ProductName.YourApp" type="win32"/>
|
||||
<description>Your application description here.</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
124
Projects/PStest/testps.pas
Normal file
124
Projects/PStest/testps.pas
Normal file
@ -0,0 +1,124 @@
|
||||
unit TestPS;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
type
|
||||
TStringArray = array of string;
|
||||
w_TPoint = record
|
||||
x, y:integer;
|
||||
end;
|
||||
|
||||
procedure TestParameters(Int1,Int2,Int3,Int4,Int5,Int6 : integer);
|
||||
function TestResult(Int1,Int2,Int3,Int4,Int5,Int6 : integer): Integer;
|
||||
function TestString(Str1,Str2,Str3 : string) : string;
|
||||
function TestStringEdit(var Str : string) : String;
|
||||
procedure TestArrayPassing( Arr : TStringArray);
|
||||
Procedure TestArrayEdit(var Arr : TStringArray);
|
||||
function TestArrayFull(var Arr1: TStringArray; Arr2 : TStringArray): TStringArray;
|
||||
function makePoint(x, y: integer): w_Tpoint;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Unit1;
|
||||
|
||||
procedure Writeln(s : string);
|
||||
begin;
|
||||
Form1.Memo2.Lines.add(s);
|
||||
end;
|
||||
|
||||
procedure TestParameters(Int1,Int2,Int3,Int4,Int5,Int6 : integer);
|
||||
begin;
|
||||
Writeln('Parameters are: ' + format('%d %d %d %d %d %d',[int1,int2,int3,int4,int5,int6]));
|
||||
if (int1 <> 1) or (int2 <> 2) or (int3 <> 3) or (int4 <> 4) or (int5 <> 5) or (int6 <> 6) then
|
||||
Writeln('WRONG.')
|
||||
else
|
||||
Writeln('Passed this test');
|
||||
end;
|
||||
|
||||
function TestResult(Int1,Int2,Int3,Int4,Int5,Int6 : integer): Integer;
|
||||
begin;
|
||||
Result := int1 + int2 + int3 + int4 + int5 + int6;
|
||||
Writeln('Result should be:' + inttostr(int1+int2+int3+int4+int5+int6));
|
||||
end;
|
||||
|
||||
function TestString(Str1,Str2,Str3 : string) : string;
|
||||
begin;
|
||||
if Str1+Str2+str3 = 'lol' then
|
||||
Writeln('Strings got passed over correctly.');
|
||||
Str1 := 'a';
|
||||
Str2 := 'b';
|
||||
Str3 := 'c';
|
||||
Result := str1;
|
||||
Writeln('Result should be a');
|
||||
end;
|
||||
|
||||
function TestStringEdit(var Str : string) : String;
|
||||
begin;
|
||||
Result := 'False';
|
||||
if Str <> 'Test' then
|
||||
Writeln('String didn''t get passed on right');
|
||||
Str := 'tseT';
|
||||
Result := Str;
|
||||
Result := 'hopla';
|
||||
Writeln('Result should be: hopla; Input str should be tseT');
|
||||
end;
|
||||
|
||||
procedure TestArrayPassing(Arr : TStringArray);
|
||||
var
|
||||
i : integer;
|
||||
begin;
|
||||
Writeln('Length of arr is: ' + inttostr(length(arr)));
|
||||
for i := 0 to high(arr) do
|
||||
Writeln(format('Arr[%d] := %s',[i,arr[i]]));
|
||||
end;
|
||||
|
||||
|
||||
Procedure TestArrayEdit(var Arr : TStringArray);
|
||||
begin;
|
||||
Writeln('Arr size is ' + inttostr(length(arr)));
|
||||
SetLength(arr,0);
|
||||
SetLength(arr,5);
|
||||
arr[0] := 'a';
|
||||
arr[1] := 'b';
|
||||
arr[2] := 'c';
|
||||
arr[3] := 'd';
|
||||
arr[4] := '!';
|
||||
end;
|
||||
|
||||
function ConvStrArr( Arr : Array of String): TStringArray;
|
||||
var
|
||||
Len : Integer;
|
||||
begin;
|
||||
Len := Length(Arr);
|
||||
SetLength(Result, Len);
|
||||
Move(Arr[Low(Arr)], Result[0], Len*SizeOf(String));
|
||||
end;
|
||||
|
||||
function TestArrayFull(var Arr1: TStringArray; Arr2 : TStringArray): TStringArray;
|
||||
begin
|
||||
Writeln(Format('Len(Arr1) = %d - Len(Arr2) = %d',[Length(Arr1),length(arr2)]));
|
||||
SetLength(Result,0);
|
||||
Setlength(Arr1,0);
|
||||
SetLength(Arr2,0);
|
||||
SetLength(result,3);
|
||||
SetLength(Arr1,4);
|
||||
SetLength(arr2,5);
|
||||
Arr1 := ConvStrArr(['Hoi','Hoe','Gaat','Het?']);
|
||||
Arr2 := ConvStrArr(['Ik','ben','een','geest!']);
|
||||
Result := ConvStrArr(['Waza?','Gaat','Alles','Goed']);
|
||||
end;
|
||||
|
||||
function makePoint(x, y: integer): w_Tpoint;
|
||||
begin
|
||||
result.x := x;
|
||||
result.y := y;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
84
Projects/PStest/unit1.lfm
Normal file
84
Projects/PStest/unit1.lfm
Normal file
@ -0,0 +1,84 @@
|
||||
object Form1: TForm1
|
||||
Left = 347
|
||||
Height = 300
|
||||
Top = 314
|
||||
Width = 400
|
||||
ActiveControl = Button1
|
||||
Caption = 'Bug in Pascal Script for Lazarus'
|
||||
ClientHeight = 300
|
||||
ClientWidth = 400
|
||||
LCLVersion = '0.9.29'
|
||||
object Memo1: TMemo
|
||||
Left = 0
|
||||
Height = 137
|
||||
Top = 55
|
||||
Width = 400
|
||||
Align = alBottom
|
||||
Lines.Strings = (
|
||||
'program TestPS;'
|
||||
''
|
||||
'var'
|
||||
' Str,Str1,str2,str3 : String;'
|
||||
' Arr : TStringArray;'
|
||||
' I : integer;'
|
||||
' p: w_TPoint;'
|
||||
'begin'
|
||||
' TestParameters(1,2,3,4,5,6);'
|
||||
' if TestResult(1,2,3,4,5,6) = (1+2+3+4+5+6) then'
|
||||
' Writeln(''Result = '' + inttostr(1+2+3+4+5+6) + ''. Passed the result test'')'
|
||||
' else'
|
||||
' Writeln(''Result = '' + Inttostr(TestResult(1,2,3,4,5,6)) +'
|
||||
' ''. Failed @ result test'');'
|
||||
' p := makePoint(2,2);'
|
||||
' writeln(''p: '' + inttostr(p.x) + '', '' + inttostr(p.y));'
|
||||
' Str1 := ''l'';'
|
||||
' Str2 := ''o'';'
|
||||
' Str3 := ''l'';'
|
||||
' if TestString(Str1,Str2,Str3) = ''a'' then'
|
||||
' Writeln(''String test succesful.'')'
|
||||
' else'
|
||||
' Writeln(''String test failed.'');'
|
||||
' if (str1 = ''l'') and (str2 = ''o'') and (str3 = ''l'') then'
|
||||
' Writeln(''String test passed again.'')'
|
||||
' else'
|
||||
' Writeln(''String test failed.'');'
|
||||
' Str := ''Test'';'
|
||||
' if TestStringEdit(Str) = ''hopla'' then'
|
||||
' Writeln(''TestStringEdit result passed.'')'
|
||||
' else'
|
||||
' Writeln(''TestStringEdit result failed.'');'
|
||||
' if Str = ''tseT'' then'
|
||||
' Writeln(''TestStringEdit input passed.'')'
|
||||
' else'
|
||||
' Writeln(''TestStringEdit input failed.'');'
|
||||
' TestArrayEdit(Arr);'
|
||||
' For i := 0 to Length(arr) - 1 do'
|
||||
' Writeln(Arr[i]); '
|
||||
' Writeln(''it shouldve written: "abcd!"'');'
|
||||
' Arr := TStringArray([''Dit'',''is'',''een'',''test'']);'
|
||||
' TestArrayPassing(arr);'
|
||||
' TestArrayPassing(TStringArray([''Dit'',''is'',''een'',''test'']));'
|
||||
'end.'
|
||||
)
|
||||
OnChange = Memo1Change
|
||||
TabOrder = 0
|
||||
end
|
||||
object Memo2: TMemo
|
||||
Left = 0
|
||||
Height = 108
|
||||
Top = 192
|
||||
Width = 400
|
||||
Align = alBottom
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button1: TButton
|
||||
Left = 0
|
||||
Height = 55
|
||||
Top = 0
|
||||
Width = 400
|
||||
Align = alClient
|
||||
Caption = 'Compile'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
35
Projects/PStest/unit1.lrs
Normal file
35
Projects/PStest/unit1.lrs
Normal file
@ -0,0 +1,35 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TForm1','FORMDATA',[
|
||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'['#1#6'Height'#3','#1#3'Top'#3':'#1#5'Wid'
|
||||
+'th'#3#144#1#13'ActiveControl'#7#7'Button1'#7'Caption'#6' Bug in Pascal Scri'
|
||||
+'pt for Lazarus'#12'ClientHeight'#3','#1#11'ClientWidth'#3#144#1#10'LCLVersi'
|
||||
+'on'#6#6'0.9.29'#0#5'TMemo'#5'Memo1'#4'Left'#2#0#6'Height'#3#137#0#3'Top'#2
|
||||
+'7'#5'Width'#3#144#1#5'Align'#7#8'alBottom'#13'Lines.Strings'#1#6#15'program'
|
||||
+' TestPS;'#6#0#6#3'var'#6#30' Str,Str1,str2,str3 : String;'#6#21' Arr : TS'
|
||||
+'tringArray;'#6#14' I : integer;'#6#14' p: w_TPoint;'#6#5'begin'#6#30' Te'
|
||||
+'stParameters(1,2,3,4,5,6);'#6'1 if TestResult(1,2,3,4,5,6) = (1+2+3+4+5+6)'
|
||||
+' then'#6'M Writeln(''Result = '' + inttostr(1+2+3+4+5+6) + ''. Passed th'
|
||||
+'e result test'')'#6#6' else'#6'> Writeln(''Result = '' + Inttostr(Test'
|
||||
+'Result(1,2,3,4,5,6)) +'#6#31' ''. Failed @ result test'');'#6#22' p :='
|
||||
+' makePoint(2,2);'#6'8 writeln(''p: '' + inttostr(p.x) + '', '' + inttostr('
|
||||
+'p.y));'#6#14' Str1 := ''l'';'#6#14' Str2 := ''o'';'#6#14' Str3 := ''l'';'
|
||||
+#6'* if TestString(Str1,Str2,Str3) = ''a'' then'#6'% Writeln(''String te'
|
||||
+'st succesful.'')'#6#6' else'#6'# Writeln(''String test failed.'');'#6'8'
|
||||
+' if (str1 = ''l'') and (str2 = ''o'') and (str3 = ''l'') then'#6'( Writ'
|
||||
+'eln(''String test passed again.'')'#6#6' else'#6'# Writeln(''String tes'
|
||||
+'t failed.'');'#6#16' Str := ''Test'';'#6''' if TestStringEdit(Str) = ''ho'
|
||||
+'pla'' then'#6', Writeln(''TestStringEdit result passed.'')'#6#6' else'#6
|
||||
+'- Writeln(''TestStringEdit result failed.'');'#6#22' if Str = ''tseT'' '
|
||||
+'then'#6'+ Writeln(''TestStringEdit input passed.'')'#6#6' else'#6', '
|
||||
+'Writeln(''TestStringEdit input failed.'');'#6#21' TestArrayEdit(Arr);'#6'"'
|
||||
+' For i := 0 to Length(arr) - 1 do'#6#21' Writeln(Arr[i]); '#6'* Writel'
|
||||
+'n(''it shouldve written: "abcd!"'');'#6'1 Arr := TStringArray([''Dit'',''i'
|
||||
+'s'',''een'',''test'']);'#6#24' TestArrayPassing(arr);'#6'< TestArrayPassi'
|
||||
+'ng(TStringArray([''Dit'',''is'',''een'',''test'']));'#6#4'end.'#0#8'OnChang'
|
||||
+'e'#7#11'Memo1Change'#8'TabOrder'#2#0#0#0#5'TMemo'#5'Memo2'#4'Left'#2#0#6'He'
|
||||
+'ight'#2'l'#3'Top'#3#192#0#5'Width'#3#144#1#5'Align'#7#8'alBottom'#8'TabOrde'
|
||||
+'r'#2#1#0#0#7'TButton'#7'Button1'#4'Left'#2#0#6'Height'#2'7'#3'Top'#2#0#5'Wi'
|
||||
+'dth'#3#144#1#5'Align'#7#8'alClient'#7'Caption'#6#7'Compile'#7'OnClick'#7#12
|
||||
+'Button1Click'#8'TabOrder'#2#2#0#0#0
|
||||
]);
|
180
Projects/PStest/unit1.pas
Normal file
180
Projects/PStest/unit1.pas
Normal file
@ -0,0 +1,180 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, uPSComponent, uPSCompiler, uPSRuntime,UPSUtils,testps;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Button1: TButton;
|
||||
Memo1: TMemo;
|
||||
Memo2: TMemo;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Memo1Change(Sender: TObject);
|
||||
procedure ScriptCompile(Sender: TPSScript);
|
||||
procedure ScriptCompImport(Sender: TObject; x: TPSPascalCompiler);
|
||||
procedure ScriptExecImport(Sender: TObject; se: TPSExec;
|
||||
x: TPSRuntimeClassImporter);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
uses
|
||||
uPSR_std,
|
||||
uPSC_std,
|
||||
uPSR_stdctrls,
|
||||
uPSC_stdctrls,
|
||||
uPSR_forms,
|
||||
uPSC_forms,
|
||||
uPSC_graphics,
|
||||
uPSC_controls,
|
||||
uPSC_classes,
|
||||
uPSR_graphics,
|
||||
uPSR_controls,
|
||||
uPSR_classes;
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var
|
||||
Script : TPSScript;
|
||||
procedure OutputMessages;
|
||||
var
|
||||
l: Longint;
|
||||
b: Boolean;
|
||||
begin
|
||||
b := False;
|
||||
|
||||
for l := 0 to Script.CompilerMessageCount - 1 do
|
||||
begin
|
||||
Memo2.Lines.Add('Compiler: '+ Script.CompilerErrorToStr(l));
|
||||
if (not b) and (Script.CompilerMessages[l] is TIFPSPascalCompilerError) then
|
||||
begin
|
||||
b := True;
|
||||
Memo1.SelStart := Script.CompilerMessages[l].Pos;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
begin
|
||||
Script := TPSScript.Create(self);
|
||||
Script.OnCompImport:=@ScriptCompImport;
|
||||
Script.OnExecImport:=@ScriptExecImport;
|
||||
Script.OnCompile:=@ScriptCompile;
|
||||
Memo2.Lines.Clear;
|
||||
Script.Script.Assign(Memo1.Lines);
|
||||
Memo2.Lines.Add('Compiling');
|
||||
if Script.Compile then
|
||||
begin
|
||||
OutputMessages;
|
||||
Memo2.Lines.Add('Compiled succesfully');
|
||||
if not Script.Execute then
|
||||
begin
|
||||
Memo1.SelStart := Script.ExecErrorPosition;
|
||||
Memo2.Lines.Add(Script.ExecErrorToString +' at '+Inttostr(Script.ExecErrorProcNo)+'.'+Inttostr(Script.ExecErrorByteCodePosition));
|
||||
end else Memo2.Lines.Add('Succesfully executed');
|
||||
end else
|
||||
begin
|
||||
OutputMessages;
|
||||
Memo2.Lines.Add('Compiling failed');
|
||||
end;
|
||||
Script.free;
|
||||
end;
|
||||
|
||||
procedure TForm1.Memo1Change(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function teststdcall(num1,num2,num3,num4,num5,num6 : LongInt) : boolean; stdcall;
|
||||
begin;
|
||||
Result := false;
|
||||
Form1.Memo2.Lines.add(Format('stdcall AddFunctionEx: %d %d %d %d %d %d',[num1,num2,num3,num4,num5,num6]));
|
||||
end;
|
||||
|
||||
function testcdecl(num1,num2,num3,num4,num5,num6 : LongInt) : boolean; cdecl;
|
||||
begin;
|
||||
Result := false;
|
||||
Form1.Memo2.Lines.add(Format('cdecl AddFunctionEx: %d %d %d %d %d %d',[num1,num2,num3,num4,num5,num6]));
|
||||
end;
|
||||
|
||||
|
||||
function testnormal(num1,num2,num3,num4,num5,num6 : LongInt) : boolean;
|
||||
begin;
|
||||
Result := false;
|
||||
Form1.Memo2.Lines.add(Format('Normal AddFunction: %d %d %d %d %d %d',[num1,num2,num3,num4,num5,num6]));
|
||||
end;
|
||||
|
||||
function DiffTest(num : integer; str : string; byt : byte; wor : longword; bool : boolean) : boolean;
|
||||
begin;
|
||||
Result := false;
|
||||
Form1.Memo2.Lines.add(inttostr(num) + '-' + str +'-' + inttostr(byt) +'-' + inttostr(wor) +'-' + booltostr(bool,true));
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.ScriptCompImport(Sender: TObject; x: TPSPascalCompiler);
|
||||
begin
|
||||
SIRegister_Std(x);
|
||||
SIRegister_Classes(x, true);
|
||||
SIRegister_Graphics(x, true);
|
||||
SIRegister_Controls(x);
|
||||
SIRegister_stdctrls(x);
|
||||
SIRegister_Forms(x);
|
||||
end;
|
||||
|
||||
procedure TForm1.ScriptExecImport(Sender: TObject; se: TPSExec;
|
||||
x: TPSRuntimeClassImporter);
|
||||
begin
|
||||
RIRegister_Std(x);
|
||||
RIRegister_Classes(x, True);
|
||||
RIRegister_Graphics(x, True);
|
||||
RIRegister_Controls(x);
|
||||
RIRegister_stdctrls(x);
|
||||
RIRegister_Forms(x);
|
||||
end;
|
||||
|
||||
procedure Writeln(s : string);
|
||||
begin;
|
||||
Form1.Memo2.Lines.add(s);
|
||||
end;
|
||||
|
||||
procedure TForm1.ScriptCompile(Sender: TPSScript);
|
||||
begin
|
||||
Sender.Comp.AddTypeS('TStringArray','Array of string');
|
||||
Sender.Comp.AddTypeS('w_TPoint', 'record x, y: integer; end;');
|
||||
Sender.AddFunction(@Writeln,'procedure writeln(s:string)');
|
||||
Sender.AddFunction(@testnormal,'function testnormal(num1,num2,num3,num4,num5,num6 : LongInt) : boolean;');
|
||||
Sender.AddFunctionEx(@teststdcall, 'function teststdcall(num1,num2,num3,num4,num5,num6 : LongInt) : boolean;stdcall;',cdStdCall);
|
||||
Sender.AddFunctionEx(@testcdecl, 'function testcdecl(num1,num2,num3,num4,num5,num6 : LongInt) : boolean; cdecl;',cdCdecl);
|
||||
Sender.AddFunction(@DiffTest,'function DiffTest(num : integer; str : string; byt : byte; wor : longword; bool : boolean) : boolean;');
|
||||
Sender.AddFunction(@TestParameters,'procedure TestParameters(Int1,Int2,Int3,Int4,Int5,Int6 : integer);');
|
||||
Sender.AddFunction(@TestResult,'function TestResult(Int1,Int2,Int3,Int4,Int5,Int6 : integer): Integer;');
|
||||
Sender.AddFunction(@TestString,'function TestString(Str1,Str2,Str3 : string) : string;');
|
||||
Sender.AddFunction(@TestStringEdit,'function TestStringEdit(var Str : string) : String;');
|
||||
Sender.AddFunction(@TestArrayPassing,'procedure TestArrayPassing(const Arr : TStringArray);');
|
||||
Sender.AddFunction(@TestArrayEdit,'Procedure TestArrayEdit(var Arr : TStringArray);');
|
||||
Sender.AddFunction(@TestArrayFull,'function TestArrayFull(var Arr1: TStringArray; Arr2 : TStringArray): TStringArray;');
|
||||
Sender.AddFunction(@makePoint, 'function makePoint(x, y: integer): w_Tpoint;');
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
{$I unit1.lrs}
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user