mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-05 04:17:54 +02:00
* Add streaming tests
This commit is contained in:
parent
b07f70c6b2
commit
d7f9db17ed
42
test/frmrtlrun.pp
Normal file
42
test/frmrtlrun.pp
Normal file
@ -0,0 +1,42 @@
|
||||
unit frmrtlrun;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, fpcunitreport, BrowserConsole, web;
|
||||
|
||||
Type
|
||||
|
||||
{ TConsoleRunner }
|
||||
|
||||
TConsoleRunner = Class(TRunForm)
|
||||
Private
|
||||
FRun : TJSHTMLButtonElement;
|
||||
function DoRunTest(aEvent: TJSMouseEvent): boolean;
|
||||
public
|
||||
procedure initialize; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TConsoleRunner }
|
||||
|
||||
function TConsoleRunner.DoRunTest(aEvent: TJSMouseEvent): boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
ResetConsole;
|
||||
If Assigned(OnRun) then
|
||||
OnRun(Self);
|
||||
end;
|
||||
|
||||
procedure TConsoleRunner.initialize;
|
||||
begin
|
||||
FRun:=TJSHTMLButtonElement(document.getElementById('RunTest'));
|
||||
FRun.onClick:=@DoRunTest;
|
||||
ResetConsole;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
2147
test/tccompstreaming.pp
Normal file
2147
test/tccompstreaming.pp
Normal file
File diff suppressed because it is too large
Load Diff
760
test/tcstream.pp
Normal file
760
test/tcstream.pp
Normal file
@ -0,0 +1,760 @@
|
||||
unit tcstream;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testregistry;
|
||||
|
||||
type
|
||||
{ TTestStream }
|
||||
|
||||
TTestStream= class(TTestCase)
|
||||
protected
|
||||
FStream : TStream;
|
||||
procedure SetUp; override;
|
||||
procedure TearDown; override;
|
||||
procedure AssertBytes(B : Array of Byte; aMessage : string = ''; ObserveEndian : Boolean = True); overload;
|
||||
// procedure AssertBytes(B : TBytes; aMessage : string = '');overload;
|
||||
Function CreateBytes(aCount : integer) : TBytes;
|
||||
Property Stream : TStream Read FStream;
|
||||
published
|
||||
procedure TestHookUp;
|
||||
Procedure TestBytes;
|
||||
Procedure TestBytesLarge;
|
||||
Procedure TestBytesLargeCopy;
|
||||
Procedure TestByte;
|
||||
Procedure TestByteBuffer;
|
||||
Procedure TestInt8;
|
||||
Procedure TestInt8Buffer;
|
||||
Procedure TestUInt8;
|
||||
Procedure TestUInt8Buffer;
|
||||
Procedure TestSmallint;
|
||||
Procedure TestSmallintBuffer;
|
||||
Procedure TestInt16;
|
||||
Procedure TestInt16Neg;
|
||||
Procedure TestInt16Buffer;
|
||||
Procedure TestUInt16;
|
||||
Procedure TestUInt16Buffer;
|
||||
Procedure TestInt32;
|
||||
Procedure TestInt32Neg;
|
||||
Procedure TestInt32Buffer;
|
||||
Procedure TestUInt32;
|
||||
Procedure TestUInt32Buffer;
|
||||
Procedure TestInt64;
|
||||
Procedure TestInt64Neg;
|
||||
Procedure TestInt64Buffer;
|
||||
Procedure TestBoolean;
|
||||
Procedure TestBooleanBuffer;
|
||||
Procedure TestWideChar;
|
||||
Procedure TestWideCharBuffer;
|
||||
Procedure TestDouble;
|
||||
Procedure TestDoubleBuffer;
|
||||
{$ifndef ECMASCRIPT}
|
||||
Procedure TestAnsiChar;
|
||||
Procedure TestAnsicharBuffer;
|
||||
Procedure TestSingle;
|
||||
Procedure TestSingleBuffer;
|
||||
Procedure TestExtended;
|
||||
Procedure TestExtendedBuffer;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{ TTestBigendianStream }
|
||||
|
||||
TTestBigendianStream= class(TTestStream)
|
||||
Public
|
||||
Procedure Setup; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestBigendianStream }
|
||||
|
||||
procedure TTestBigendianStream.Setup;
|
||||
begin
|
||||
inherited Setup;
|
||||
Stream.Endian:=Tendian.Big;
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestHookUp;
|
||||
begin
|
||||
AssertNotNull('Have Stream',Stream);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestBytes;
|
||||
|
||||
Var
|
||||
B : TBytes;
|
||||
|
||||
begin
|
||||
B:=CreateBytes(4);
|
||||
Stream.Write(B,4);
|
||||
AssertBytes(B,'Bytes, ignoring endianness',False);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestBytesLarge;
|
||||
|
||||
Var
|
||||
B : TBytes;
|
||||
begin
|
||||
B:=CreateBytes(8000);
|
||||
Stream.Write(B,Length(B));
|
||||
AssertBytes(B,'Bytes, ignoring endianness',False);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestBytesLargeCopy;
|
||||
Var
|
||||
B : TBytes;
|
||||
S : TStream;
|
||||
begin
|
||||
S:=TBytesStream.Create([]);
|
||||
B:=CreateBytes(8000);
|
||||
S.Write(B,Length(B));
|
||||
Stream.CopyFrom(S,0);
|
||||
S.Free;
|
||||
AssertBytes(B,'Bytes, ignoring endianness',False);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestByte;
|
||||
|
||||
Var
|
||||
S,D : Byte;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=13;
|
||||
AssertEquals('Bytes written',1,Stream.WriteData(S));
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',1,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestByteBuffer;
|
||||
|
||||
Var
|
||||
S,D : Byte;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=13;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt8;
|
||||
|
||||
Var
|
||||
S,D : Int8;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=-13;
|
||||
AssertEquals('Bytes written',1,Stream.WriteData(S));
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',1,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt8Buffer;
|
||||
Var
|
||||
S,D : Int8;
|
||||
begin
|
||||
D:=0;
|
||||
S:=-13;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt8;
|
||||
Var
|
||||
S,D : UInt8;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=139;
|
||||
AssertEquals('Bytes written',1,Stream.WriteData(S));
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',1,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt8Buffer;
|
||||
Var
|
||||
S,D : UInt8;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=139;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([S]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestSmallint;
|
||||
Var
|
||||
S,D : SmallInt;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=127*256+13;
|
||||
AssertEquals('Bytes written',2,Stream.WriteData(S));
|
||||
AssertBytes([13,127]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',2,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestSmallintBuffer;
|
||||
|
||||
Var
|
||||
S,D : SmallInt;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=127*256+13;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([13,127]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt16;
|
||||
|
||||
Var
|
||||
S,D : Int16;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=127*256+13;
|
||||
AssertEquals('Bytes written',2,Stream.WriteData(S));
|
||||
AssertBytes([13,127]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',2,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt16Neg;
|
||||
Var
|
||||
S,D : Int16;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=-4086; // $F00A;
|
||||
AssertEquals('Bytes written',2,Stream.WriteData(S));
|
||||
AssertBytes([$0A,$F0]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',2,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt16Buffer;
|
||||
|
||||
Var
|
||||
S,D : Int16;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=127*256+13;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([13,127]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt16;
|
||||
|
||||
Var
|
||||
S,D : UInt16;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=$F00A; // 61450
|
||||
AssertEquals('Bytes written',2,Stream.WriteData(S));
|
||||
AssertBytes([$0A,$F0]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',2,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt16Buffer;
|
||||
Var
|
||||
S,D : UInt16;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=$F00A;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([$0A,$F0]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt32;
|
||||
|
||||
Var
|
||||
S,D : Int32;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 2131560201
|
||||
S:=(127 shl 24) + (13 shl 16) + (7 shl 8) + 9;
|
||||
AssertEquals('Bytes written',4,Stream.WriteData(S));
|
||||
AssertBytes([9,7,13,127]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',4,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt32Neg;
|
||||
|
||||
Var
|
||||
S,D : Int32;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// -2146629879
|
||||
S:=Int32((128 shl 24) + (13 shl 16) + (7 shl 8) + 9);
|
||||
AssertEquals('Bytes written',4,Stream.WriteData(S));
|
||||
AssertBytes([9,7,13,128]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',4,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt32Buffer;
|
||||
|
||||
Var
|
||||
S,D : Int32;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 2131560201
|
||||
S:=(127 shl 24) + (13 shl 16) + (7 shl 8) + 9;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([9,7,13,127]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt32;
|
||||
|
||||
Var
|
||||
S,D : UInt32;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 2148337417
|
||||
S:=UINT32((128 shl 24) + (13 shl 16) + (7 shl 8) + 9);
|
||||
AssertEquals('Bytes written',4,Stream.WriteData(S));
|
||||
AssertBytes([9,7,13,128]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',4,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestUInt32Buffer;
|
||||
|
||||
Var
|
||||
S,D : UInt32;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 2148337417
|
||||
S:=UINT32((128 shl 24) + (13 shl 16) + (7 shl 8) + 9);
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([9,7,13,128]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt64;
|
||||
|
||||
Var
|
||||
S,D : {$IFDEF ECMASCRIPT}NativeLargeInt{$else}Int64{$endif};
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 9154981354848060679
|
||||
// Javascript only has 52 bits : 7737333974279
|
||||
S:={$IFNDEF ECMASCRIPT} (127 shl 24) + (13 shl 16) {$endif}+ (7 shl 8) + 9;
|
||||
S:=(S shl 32) + ((125 shl 24) + (11 shl 16) + (5 shl 8) + 7);
|
||||
AssertEquals('Bytes written',8,Stream.WriteData(S));
|
||||
{$ifndef ECMASCRIPT}
|
||||
AssertBytes([7,5,11,125,9,7,{$IFNDEF ECMASCRIPT} 13,127 {$ELSE} 0,0 {$ENDIF}]);
|
||||
{$ENDIF}
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',8,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt64Neg;
|
||||
Var
|
||||
S,D : {$IFDEF ECMASCRIPT}NativeLargeInt{$else}Int64{$endif};
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
{$IFNDEF ECMASCRIPT}
|
||||
// -9219705124773231353
|
||||
S:=Int64((128 shl 24) + (13 shl 16) + (7 shl 8) + 9);
|
||||
S:=Int64((S shl 32) + ((128 shl 24) + (11 shl 16) + (5 shl 8) + 7));
|
||||
AssertEquals('Bytes written',8,Stream.WriteData(S));
|
||||
AssertBytes([7,5,11,128,9,7,13,128]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',8,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
{$ELSE}
|
||||
S:=-9000199254740991;
|
||||
AssertEquals('Bytes written',8,Stream.WriteData(S));
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',8,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestInt64Buffer;
|
||||
|
||||
Var
|
||||
S,D : {$IFDEF ECMASCRIPT}NativeLargeInt{$else}Int64{$endif};
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
// 9154981354848060679
|
||||
// 7737333974279 for ECMAScript
|
||||
S:={$IFNDEF ECMASCRIPT} (127 shl 24) + (13 shl 16) {$endif}+ (7 shl 8) + 9;
|
||||
S:=(S shl 32) + ((125 shl 24) + (11 shl 16) + (5 shl 8) + 7);
|
||||
Stream.WriteBufferData(S);
|
||||
{$IFNDEF ECMASCRIPT}
|
||||
AssertBytes([7,5,11,125,9,7,13,127]);
|
||||
{$ENDIF}
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestBoolean;
|
||||
|
||||
Var
|
||||
S,D : Boolean;
|
||||
|
||||
begin
|
||||
D:=False;
|
||||
// 9154981354848060679
|
||||
S:=True;
|
||||
AssertEquals('Bytes written',1,Stream.WriteData(S));
|
||||
AssertBytes([1]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',1,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestBooleanBuffer;
|
||||
Var
|
||||
S,D : Boolean;
|
||||
|
||||
begin
|
||||
D:=False;
|
||||
// 9154981354848060679
|
||||
S:=True;
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([1]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
{$IFNDEF ECMASCRIPT}
|
||||
procedure TTestStream.TestAnsiChar;
|
||||
|
||||
Var
|
||||
S,D : AnsiChar;
|
||||
|
||||
begin
|
||||
D:=#0;
|
||||
S:='A';
|
||||
AssertEquals('Bytes written',1,Stream.WriteData(S));
|
||||
AssertBytes([Ord(S)]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',1,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestAnsicharBuffer;
|
||||
Var
|
||||
S,D : AnsiChar;
|
||||
|
||||
begin
|
||||
D:=#0;
|
||||
S:='A';
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([Ord(S)]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure TTestStream.TestWideChar;
|
||||
|
||||
Var
|
||||
S,D : WideChar;
|
||||
|
||||
begin
|
||||
D:=#0;
|
||||
S:='A';
|
||||
AssertEquals('Bytes written',2,Stream.WriteData(S));
|
||||
AssertBytes([Ord(S),0]);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',2,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',Ord(S),Ord(D));
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestWideCharBuffer;
|
||||
Var
|
||||
S,D : WideChar;
|
||||
|
||||
begin
|
||||
D:=#0;
|
||||
S:='A';
|
||||
Stream.WriteBufferData(S);
|
||||
AssertBytes([Ord(S),0]);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',Ord(S),Ord(D));
|
||||
end;
|
||||
|
||||
{$ifndef ECMASCRIPT}
|
||||
procedure TTestStream.TestSingle;
|
||||
|
||||
Var
|
||||
S,D : Single;
|
||||
B : TBytes = Nil;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
AssertEquals('Bytes written',4,Stream.WriteData(S));
|
||||
Setlength(B,4);
|
||||
With TSingleRec(S) do
|
||||
begin
|
||||
B[0]:=Bytes[0];
|
||||
B[1]:=Bytes[1];
|
||||
B[2]:=Bytes[2];
|
||||
B[3]:=Bytes[3];
|
||||
end;
|
||||
AssertBytes(B);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',4,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestSingleBuffer;
|
||||
Var
|
||||
S,D : Single;
|
||||
B : TBytes = Nil;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
Stream.WriteBufferData(S);
|
||||
Setlength(B,4);
|
||||
With TSingleRec(S) do
|
||||
begin
|
||||
B[0]:=Bytes[0];
|
||||
B[1]:=Bytes[1];
|
||||
B[2]:=Bytes[2];
|
||||
B[3]:=Bytes[3];
|
||||
end;
|
||||
AssertBytes(B);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
|
||||
procedure TTestStream.TestDouble;
|
||||
|
||||
Var
|
||||
S,D : Double;
|
||||
B : TBytes;
|
||||
{$ifndef ECMASCRIPT}
|
||||
i : integer;
|
||||
{$endif}
|
||||
|
||||
begin
|
||||
B:=Default(TBytes);
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
AssertEquals('Bytes written',8,Stream.WriteData(S));
|
||||
Setlength(B,8);
|
||||
{$ifndef ECMASCRIPT}
|
||||
With TDoubleRec(S) do
|
||||
For I:=0 to 7 do
|
||||
B[I]:=Bytes[I];
|
||||
AssertBytes(B);
|
||||
{$endif}
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',8,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestDoubleBuffer;
|
||||
|
||||
Var
|
||||
S,D : Double;
|
||||
B : TBytes;
|
||||
{$ifndef ECMASCRIPT}
|
||||
i : integer;
|
||||
{$endif}
|
||||
|
||||
begin
|
||||
B:=Default(TBytes);
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
Stream.WriteBufferData(S);
|
||||
Setlength(B,8);
|
||||
{$ifndef ECMASCRIPT}
|
||||
With TDoubleRec(S) do
|
||||
For I:=0 to 7 do
|
||||
B[I]:=Bytes[I];
|
||||
AssertBytes(B);
|
||||
{$endif}
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
|
||||
{$ifndef ECMASCRIPT}
|
||||
procedure TTestStream.TestExtended;
|
||||
Var
|
||||
S,D : Extended;
|
||||
B : TBytes = Nil;
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
AssertEquals('Bytes written',10,Stream.WriteData(S));
|
||||
Setlength(B,10);
|
||||
With TExtended80Rec(S) do
|
||||
For I:=0 to 9 do
|
||||
B[I]:=Bytes[I];
|
||||
AssertBytes(B);
|
||||
Stream.Position:=0;
|
||||
AssertEquals('Bytes read',10,Stream.ReadData(D));
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TestExtendedBuffer;
|
||||
Var
|
||||
S,D : Extended;
|
||||
B : TBytes = Nil;
|
||||
i : integer;
|
||||
|
||||
begin
|
||||
D:=0;
|
||||
S:=123.45;
|
||||
Stream.WriteBufferData(S);
|
||||
Setlength(B,10);
|
||||
With TExtended80Rec(S) do
|
||||
For I:=0 to 9 do
|
||||
B[I]:=Bytes[I];
|
||||
AssertBytes(B);
|
||||
Stream.Position:=0;
|
||||
Stream.ReadBufferData(D);
|
||||
AssertEquals('Written data read correctly',S,D,0.0001);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure TTestStream.SetUp;
|
||||
|
||||
Var
|
||||
B : TBytes;
|
||||
|
||||
begin
|
||||
B:=Default(TBytes);
|
||||
SetLength(B,0);
|
||||
FStream:=TBytesStream.Create(B);
|
||||
end;
|
||||
|
||||
procedure TTestStream.TearDown;
|
||||
begin
|
||||
FreeAndNil(FStream);
|
||||
end;
|
||||
|
||||
procedure TTestStream.AssertBytes(B: array of Byte; aMessage: string = ''; ObserveEndian : Boolean = True);
|
||||
Var
|
||||
L,I,E: integer;
|
||||
A : Byte;
|
||||
SB : TBytes;
|
||||
|
||||
begin
|
||||
if AMessage<>'' then
|
||||
aMessage:=aMessage+': ';
|
||||
AssertEquals(aMessage+'Length bytes equals',Length(B),FStream.Size);
|
||||
SB:=TBytesStream(Stream).Bytes;
|
||||
L:=Length(B);
|
||||
for I:=0 to L-1 do
|
||||
begin
|
||||
E:=Byte(B[i] and $FF);
|
||||
if ObserveEndian and (Stream.Endian=Tendian.Big) then
|
||||
A:=SB[L-1-i]
|
||||
else
|
||||
A:=SB[i];
|
||||
AssertEquals(aMessage+'Byte['+IntToStr(I)+'] equals',E,A);
|
||||
end;
|
||||
end;
|
||||
|
||||
{
|
||||
procedure TTestStream.AssertBytes(B: TBytes; aMessage : string = '');
|
||||
|
||||
Var
|
||||
I : integer;
|
||||
SB : TBytes;
|
||||
|
||||
begin
|
||||
if AMessage<>'' then
|
||||
aMessage:=aMessage+': ';
|
||||
AssertEquals(aMessage+'Length bytes equals',Length(B),FStream.Size);
|
||||
SB:=TBytesStream(Stream).Bytes;
|
||||
for I:=0 to Length(B)-1 do
|
||||
AssertEquals(aMessage+'Byte['+IntToStr(I)+'] equals',B[i],SB[i]);
|
||||
end;
|
||||
}
|
||||
function TTestStream.CreateBytes(aCount: integer): TBytes;
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
|
||||
begin
|
||||
Result:=Nil;
|
||||
SetLength(Result,aCount);
|
||||
For I:=0 to aCount-1 do
|
||||
Result[I]:=I+1;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
// RegisterTests([TTestStream,TTestBigendianStream]);
|
||||
end.
|
||||
|
417
test/tcstreaming.pp
Normal file
417
test/tcstreaming.pp
Normal file
@ -0,0 +1,417 @@
|
||||
{$mode objfpc}
|
||||
{$h+}
|
||||
unit tcstreaming;
|
||||
|
||||
interface
|
||||
|
||||
Uses
|
||||
SysUtils,Classes, fpcunit, testregistry;
|
||||
|
||||
Type
|
||||
|
||||
{ TTestStreaming }
|
||||
|
||||
TTestStreaming = Class(TTestCase)
|
||||
Private
|
||||
FStream : TMemoryStream;
|
||||
Function ReadByte : byte;
|
||||
Function ReadWord : Word;
|
||||
Function ReadInteger : LongInt;
|
||||
Function ReadNativeInt : NativeInt;
|
||||
function ReadBareStr: string;
|
||||
function ReadString(V : TValueType): string;
|
||||
function ReadWideString(V : TValueType): WideString;
|
||||
Procedure Fail(Fmt : String; Args : Array of JSValue); overload;
|
||||
Public
|
||||
Procedure Setup; override;
|
||||
Procedure TearDown; override;
|
||||
Procedure ResetStream;
|
||||
Procedure SaveToStream(C : TComponent);
|
||||
Procedure LoadFromStream(C : TComponent);
|
||||
Function ReadValue : TValueType;
|
||||
Procedure ExpectValue(AValue : TValueType);
|
||||
Procedure ExpectFlags(Flags : TFilerFlags; APosition : Integer);
|
||||
Procedure ExpectInteger(AValue : Integer);
|
||||
Procedure ExpectByte(AValue : Byte);
|
||||
Procedure ExpectInt64(AValue : Int64);
|
||||
Procedure ExpectBareString(AValue : String);
|
||||
Procedure ExpectString(AValue : String);
|
||||
Procedure ExpectSingle(AValue : Single);
|
||||
Procedure ExpectExtended(AValue : Extended);
|
||||
Procedure ExpectCurrency(AValue : Currency);
|
||||
Procedure ExpectIdent(AValue : String);
|
||||
Procedure ExpectDate(AValue : TDateTime);
|
||||
Procedure ExpectWideString(AValue : WideString);
|
||||
Procedure ExpectEndofList;
|
||||
Procedure ExpectSignature;
|
||||
Procedure ExpectEndOfStream;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses typinfo;
|
||||
|
||||
Function ValName(V : TValueType) : String;
|
||||
|
||||
begin
|
||||
Result:=GetEnumName(TypeInfo(TValueType),Ord(v));
|
||||
end;
|
||||
|
||||
{ TTestStreaming }
|
||||
|
||||
|
||||
procedure TTestStreaming.ExpectByte(AValue: Byte);
|
||||
|
||||
Var
|
||||
B : Byte;
|
||||
|
||||
begin
|
||||
B:=ReadByte;
|
||||
If (B<>AValue) then
|
||||
Fail('Expected byte %d, got %d',[AValue,B]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectCurrency(AValue: Currency);
|
||||
|
||||
Var
|
||||
C : Double;
|
||||
|
||||
begin
|
||||
ExpectValue(vaCurrency);
|
||||
FStream.ReadBufferData(C);
|
||||
If (C<>AValue) then
|
||||
Fail('Expected currency %f, got %f',[AValue,C]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectDate(AValue: TDateTime);
|
||||
|
||||
Var
|
||||
C : TDateTime;
|
||||
|
||||
begin
|
||||
ExpectValue(vaDate);
|
||||
FStream.ReadBufferData(C);
|
||||
If (C<>AValue) then
|
||||
Fail('Expected datetime %f, got %f',[AValue,C]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectEndofList;
|
||||
begin
|
||||
ExpectValue(vaNull);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectExtended(AValue: Extended);
|
||||
|
||||
Var
|
||||
E : Extended;
|
||||
|
||||
begin
|
||||
ExpectValue(vaExtended);
|
||||
FStream.ReadBufferData(E);
|
||||
If Abs(E-AValue)>0.01 then
|
||||
Fail('Expected extended %f, got %f',[AValue,E]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectFlags(Flags: TFilerFlags;
|
||||
APosition: Integer);
|
||||
|
||||
var
|
||||
FF : TFilerFlag;
|
||||
F : TFilerFlags;
|
||||
B : Byte;
|
||||
I : Integer;
|
||||
|
||||
begin
|
||||
F := [];
|
||||
I:=0;
|
||||
B:=ReadByte;
|
||||
if (B and $F0) = $F0 then
|
||||
begin
|
||||
F:=[];
|
||||
for FF in TFilerFlag do
|
||||
if (B and (1 shl ord(FF)))<>0 then
|
||||
Include(F,FF);
|
||||
if ffChildPos in Flags then
|
||||
I:=ReadInteger;
|
||||
end
|
||||
else
|
||||
FStream.Position:=FStream.Position-1;
|
||||
If (FLags<>F) then
|
||||
Fail('Wrong Flags');
|
||||
If I<>APosition then
|
||||
Fail('Wrong position, expected %d, got %d',[APosition,I]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectIdent(AValue: String);
|
||||
|
||||
var
|
||||
I,L : Byte;
|
||||
V : TValueType;
|
||||
S : String;
|
||||
C : Char;
|
||||
begin
|
||||
V:=ReadValue;
|
||||
case V of
|
||||
vaIdent:
|
||||
begin
|
||||
L:=ReadByte;
|
||||
SetLength(S,L);
|
||||
for I:=1 to L do
|
||||
begin
|
||||
FStream.ReadBufferData(C);
|
||||
S[i]:=C;
|
||||
end;
|
||||
end;
|
||||
vaFalse:
|
||||
S := 'False';
|
||||
vaTrue:
|
||||
S := 'True';
|
||||
vaNil:
|
||||
S := 'nil';
|
||||
vaNull:
|
||||
S := 'Null';
|
||||
else
|
||||
Fail(Format('Expected identifier property type, got %s',[valName(V)]));
|
||||
end;
|
||||
If (S<>AValue) then
|
||||
Fail(Format('Wrong identifier %s, expected %s',[S,AValue]));
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectInt64(AValue: Int64);
|
||||
|
||||
Var
|
||||
V : TValueType;
|
||||
I : Int64;
|
||||
|
||||
begin
|
||||
V:=ReadValue;
|
||||
Case V of
|
||||
vaInt8 : I:=ReadByte;
|
||||
vaInt16 : I:=ReadWord;
|
||||
vaInt32 : I:=ReadInteger;
|
||||
vaInt64 : I:=ReadNativeInt;
|
||||
else
|
||||
Fail(Format('Expected integer property type, got %s',[valName(V)]));
|
||||
end;
|
||||
If (AValue<>I) then
|
||||
Fail(Format('Expected integer %d, but got %d',[AValue,I]));
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectInteger(AValue: Integer);
|
||||
|
||||
Var
|
||||
V : TValueType;
|
||||
I : Integer;
|
||||
|
||||
begin
|
||||
V:=ReadValue;
|
||||
Case V of
|
||||
vaInt8 : I:=ReadByte;
|
||||
vaInt16 : I:=ReadWord;
|
||||
vaInt32 : I:=ReadInteger;
|
||||
else
|
||||
Fail('Expected integer property type, got %s',[valName(V)]);
|
||||
end;
|
||||
If (AValue<>I) then
|
||||
Fail('Expected integer %d, but got %d',[AValue,I]);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TTestStreaming.ExpectSignature;
|
||||
|
||||
const
|
||||
// Sig : array[1..4] of Char = 'TPF0';
|
||||
// Integer version of 4 chars 'TPF0'
|
||||
FilerSignatureInt = 809914452;
|
||||
|
||||
var
|
||||
E,L : Longint;
|
||||
|
||||
begin
|
||||
L:=ReadInteger;
|
||||
E:=FilerSignatureInt;
|
||||
if L<>E then
|
||||
Fail('Invalid signature %d, expected %d',[L,E]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectSingle(AValue: Single);
|
||||
|
||||
Var
|
||||
S : Double;
|
||||
|
||||
begin
|
||||
ExpectValue(vaSingle);
|
||||
FStream.ReadBufferData(S);
|
||||
If Abs(AValue-S)>0.0001 then
|
||||
Fail('Expected single %f, but got %s',[AValue,S]);
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadString(V : TValueType): string;
|
||||
|
||||
var
|
||||
L,I : Integer;
|
||||
C : Char;
|
||||
|
||||
begin
|
||||
// There is only 1 string type
|
||||
if V<>vaString then
|
||||
Fail('Wrong type %s, expected string type.',[ValName(V)]);
|
||||
L := 0;
|
||||
FStream.ReadBufferData(L);
|
||||
SetLength(Result, L);
|
||||
For I:=1 to L do
|
||||
begin
|
||||
FStream.ReadBufferData(C);
|
||||
Result[i]:=C;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadWideString(V : TValueType): WideString;
|
||||
|
||||
begin
|
||||
Result := ReadString(V)
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectString(AValue: String);
|
||||
|
||||
Var
|
||||
V : TValueType;
|
||||
S : String;
|
||||
begin
|
||||
V:=ReadValue;
|
||||
If v in [vaString,vaLstring,vaWString,vaUTF8String] then
|
||||
S:=ReadString(V)
|
||||
else
|
||||
Fail('Expected string type, but got : %s',[ValName(V)]);
|
||||
If (S<>AValue) then
|
||||
Fail('Expected string "%s", but got "%s"',[AVAlue,S]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectValue(AValue: TValueType);
|
||||
|
||||
Var
|
||||
V : TValueType;
|
||||
|
||||
begin
|
||||
V:=ReadValue;
|
||||
If (V<>AValue) then
|
||||
Fail('Expecting value %s, but read %s',[ValName(AValue),ValName(V)]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectWideString(AValue: WideString);
|
||||
|
||||
Var
|
||||
W : WideString;
|
||||
V : TValueType;
|
||||
|
||||
begin
|
||||
V:=ReadValue;
|
||||
If v in [vaString,vaLstring,vaWString,vaUTF8String] then
|
||||
W:=ReadWideString(V)
|
||||
else
|
||||
Fail('Expected string type, but got : %s',[ValName(V)]);
|
||||
If (W<>AValue) then
|
||||
Fail('Expected string "%s", but got "%s"',[AVAlue,W]);
|
||||
end;
|
||||
|
||||
|
||||
procedure TTestStreaming.Fail(Fmt: String; Args: array of jsvalue);
|
||||
begin
|
||||
Fail(Format(Fmt,Args));
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadValue: TValueType;
|
||||
|
||||
var b : byte;
|
||||
|
||||
begin
|
||||
FStream.ReadBufferData(b);
|
||||
result := TValueType(b);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.Setup;
|
||||
begin
|
||||
FStream:=TMemoryStream.Create;
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.SaveToStream(C: TComponent);
|
||||
begin
|
||||
C.Name:='Test'+C.ClassName;
|
||||
FStream.Clear;
|
||||
FStream.WriteComponent(C);
|
||||
FStream.Position:=0;
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.LoadFromStream(C: TComponent);
|
||||
begin
|
||||
ResetStream;
|
||||
FStream.ReadComponent(C);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.TearDown;
|
||||
begin
|
||||
FreeAndNil(FStream);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ResetStream;
|
||||
begin
|
||||
FStream.Position:=0;
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadByte: byte;
|
||||
begin
|
||||
FStream.ReadBufferData(Result);
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadNativeInt: NativeInt;
|
||||
|
||||
begin
|
||||
FStream.ReadBufferData(Result);
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadInteger: LongInt;
|
||||
begin
|
||||
FStream.ReadBufferData(Result);
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadWord: Word;
|
||||
begin
|
||||
FStream.ReadBufferData(Result);
|
||||
end;
|
||||
|
||||
function TTestStreaming.ReadBareStr: string;
|
||||
|
||||
var
|
||||
L,I : Integer;
|
||||
C : Char;
|
||||
|
||||
begin
|
||||
L:=ReadByte;
|
||||
SetLength(Result,L);
|
||||
for I:=1 to L do
|
||||
begin
|
||||
FStream.ReadBufferData(C);
|
||||
Result[I]:=C;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectBareString(AValue: String);
|
||||
|
||||
Var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
S:=ReadBareStr;
|
||||
If (S<>AValue) then
|
||||
Fail('Expected bare string %s, got :%s',[AValue,S]);
|
||||
end;
|
||||
|
||||
procedure TTestStreaming.ExpectEndOfStream;
|
||||
begin
|
||||
If (FStream.Position<>FStream.Size) then
|
||||
Fail('Expected at end of stream, current position=%d, size=%d',
|
||||
[FStream.Position,FStream.Size]);
|
||||
end;
|
||||
|
||||
end.
|
20
test/testrtl.html
Normal file
20
test/testrtl.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>TStream test</title>
|
||||
<script SRC="testrtl.js" type="application/javascript"></script>
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<!-- <link href="fpcunit.css" rel="stylesheet"> -->
|
||||
</head>
|
||||
<body>
|
||||
<button class="btn btn-default" id="RunTest">Run test</button>
|
||||
<div id="fpcunit-controller"></div>
|
||||
<div id="fpcunit"></div>
|
||||
<div id="pasjsconsole"></div>
|
||||
<script>
|
||||
rtl.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
113
test/testrtl.lpi
Normal file
113
test/testrtl.lpi
Normal file
@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
<Runnable Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="testrtl"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<CustomData Count="3">
|
||||
<Item0 Name="MaintainHTML" Value="1"/>
|
||||
<Item1 Name="PasJSWebBrowserProject" Value="1"/>
|
||||
<Item2 Name="RunAtReady" Value="1"/>
|
||||
</CustomData>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0"/>
|
||||
</RunParams>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="testrtl.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="testrtl.html"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CustomData Count="1">
|
||||
<Item0 Name="PasJSIsProjectHTMLFile" Value="1"/>
|
||||
</CustomData>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="frmrtlrun.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="tcstream.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="tccompstreaming.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="tcstreaming.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="testcomps.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="../packages/rtl/simplelinkedlist.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target FileExt=".js">
|
||||
<Filename Value="testrtl"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="js"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<AllowLabel Value="False"/>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<TargetOS Value="browser"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
<UseLineInfoUnit Value="False"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-Jeutf-8 -Jirtl.js -Jc"/>
|
||||
<CompilerPath Value="$(pas2js)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
17
test/testrtl.lpr
Normal file
17
test/testrtl.lpr
Normal file
@ -0,0 +1,17 @@
|
||||
program testrtl;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
browserconsole, {browsertestrunner} consoletestrunner, JS, Classes, SysUtils, Web, frmrtlrun, tcstream, tccompstreaming, simplelinkedlist;
|
||||
|
||||
var
|
||||
Application : TTestRunner;
|
||||
|
||||
begin
|
||||
Application:=TTestRunner.Create(nil);
|
||||
Application.RunFormClass:=TConsoleRunner;
|
||||
Application.Initialize;
|
||||
Application.Run;
|
||||
// Application.Free;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user