michael 6 роки тому
батько
коміт
d7f9db17ed
7 змінених файлів з 3516 додано та 0 видалено
  1. 42 0
      test/frmrtlrun.pp
  2. 2147 0
      test/tccompstreaming.pp
  3. 760 0
      test/tcstream.pp
  4. 417 0
      test/tcstreaming.pp
  5. 20 0
      test/testrtl.html
  6. 113 0
      test/testrtl.lpi
  7. 17 0
      test/testrtl.lpr

+ 42 - 0
test/frmrtlrun.pp

@@ -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 - 0
test/tccompstreaming.pp

@@ -0,0 +1,2147 @@
+Unit tccompstreaming;
+
+interface
+
+Uses
+  SysUtils, Classes, tcstreaming, fpcunit, testregistry, testcomps;
+
+Type
+
+  { TTestComponentStream }
+
+  TTestComponentStream = Class(TTestStreaming)
+  Published
+      Procedure TestTEmptyComponent;
+      Procedure TestTIntegerComponent;
+      Procedure TestTIntegerComponent2;
+      Procedure TestTIntegerComponent3;
+      Procedure TestTIntegerComponent4;
+      Procedure TestTIntegerComponent5;
+      Procedure TestTInt64Component;
+      Procedure TestTInt64Component2;
+      Procedure TestTInt64Component3;
+      Procedure TestTInt64Component4;
+      Procedure TestTInt64Component5;
+      Procedure TestTInt64Component6;
+      Procedure TestTStringComponent;
+      Procedure TestTStringComponent2;
+      Procedure TestTWideStringComponent;
+      Procedure TestTWideStringComponent2;
+      Procedure TestTSingleComponent;
+      Procedure TestTDoubleComponent;
+      Procedure TestTExtendedComponent;
+//      Procedure TestTCompComponent;
+      Procedure TestTCurrencyComponent;
+      Procedure TestTDateTimeComponent;
+      Procedure TestTDateTimeComponent2;
+      Procedure TestTDateTimeComponent3;
+      Procedure TestTEnumComponent;
+      Procedure TestTEnumComponent2;
+      Procedure TestTEnumComponent3;
+      Procedure TestTEnumComponent4;
+      Procedure TestTEnumComponent5;
+      Procedure TestTSetComponent;
+      Procedure TestTSetComponent2;
+      Procedure TestTSetComponent3;
+      Procedure TestTSetComponent4;
+      Procedure TestTMultipleComponent;
+      Procedure TestTPersistentComponent;
+      Procedure TestTCollectionComponent;
+      Procedure TestTCollectionComponent2;
+      Procedure TestTCollectionComponent3;
+      Procedure TestTCollectionComponent4;
+      Procedure TestTCollectionComponent5;
+      Procedure TestTOwnedComponent;
+      Procedure TestTStreamedOwnedComponent;
+      Procedure TestTStreamedOwnedComponents;
+      Procedure TestTMethodComponent;
+      Procedure TestTMethodComponent2;
+      // Read
+      Procedure TestTEmptyComponentRead;
+      Procedure TestTIntegerComponentRead;
+      Procedure TestTIntegerComponent2Read;
+      Procedure TestTIntegerComponent3Read;
+      Procedure TestTIntegerComponent4Read;
+      Procedure TestTIntegerComponent5Read;
+      Procedure TestTInt64ComponentRead;
+      Procedure TestTInt64Component2Read;
+      Procedure TestTInt64Component3Read;
+      Procedure TestTInt64Component4Read;
+      Procedure TestTInt64Component5Read;
+      Procedure TestTInt64Component6Read;
+      Procedure TestTStringComponentRead;
+      Procedure TestTStringComponent2Read;
+      Procedure TestTWideStringComponentRead;
+      Procedure TestTWideStringComponent2Read;
+      Procedure TestTSingleComponentRead;
+      Procedure TestTDoubleComponentRead;
+      Procedure TestTExtendedComponentRead;
+//      Procedure TestTCompComponent;
+      Procedure TestTCurrencyComponentRead;
+      Procedure TestTDateTimeComponentRead;
+      Procedure TestTDateTimeComponent2Read;
+      Procedure TestTDateTimeComponent3Read;
+      Procedure TestTEnumComponentRead;
+      Procedure TestTEnumComponent2Read;
+      Procedure TestTEnumComponent3Read;
+      Procedure TestTEnumComponent4Read;
+      Procedure TestTEnumComponent5Read;
+      Procedure TestTSetComponentRead;
+      Procedure TestTSetComponent2Read;
+      Procedure TestTSetComponent3Read;
+      Procedure TestTSetComponent4Read;
+      Procedure TestTMultipleComponentRead;
+      Procedure TestTPersistentComponentRead;
+      Procedure TestTCollectionComponentRead;
+      Procedure TestTCollectionComponent2Read;
+      Procedure TestTCollectionComponent3Read;
+      Procedure TestTCollectionComponent4Read;
+      Procedure TestTCollectionComponent5Read;
+      Procedure TestTOwnedComponentRead;
+      Procedure TestTStreamedOwnedComponentRead;
+      Procedure TestTStreamedOwnedComponentsRead;
+    end;
+
+
+  { TTestCollectionStream }
+
+  TTestCollectionStream = Class(TTestCase)
+  private
+    procedure CompareColl(CA, CB: TMyColl);
+    function CreateColl(Anr: Integer): TCollComp;
+    function EmptyComp: TCollComp;
+    procedure TestNr(ACount: Integer);
+  Published
+    procedure Test1;
+    procedure Test2;
+    procedure Test3;
+    procedure TestClear;
+    procedure TestEmpty;
+  end;
+
+Implementation
+
+Procedure TTestComponentStream.TestTEmptyComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEmptyComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEmptyComponent');
+    ExpectBareString('TestTEmptyComponent');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEmptyComponentRead;
+
+Var
+  C : TEmptyComponent;
+begin
+  TestTEmptyComponent;
+  C:=TEmptyComponent.Create(Nil);
+  try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEmptyComponent',C.Name);
+  finally
+    C.Free;
+  end;
+end;
+
+Procedure TTestComponentStream.TestTIntegerComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TIntegerComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent');
+    ExpectBareString('TestTIntegerComponent');
+    ExpectBareString('IntProp');
+    ExpectInteger(3);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTIntegerComponentRead;
+
+Var
+  C : TIntegerComponent;
+
+begin
+  TestTIntegerComponent;
+  C:=TIntegerComponent.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTIntegerComponent',C.Name);
+    AssertEquals('IntProp',3,C.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTIntegerComponent2Read;
+
+Var
+  C : TIntegerComponent2;
+
+begin
+  TestTIntegerComponent2;
+  C:=TIntegerComponent2.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTIntegerComponent2',C.Name);
+    AssertEquals('IntProp',1024,C.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTIntegerComponent3Read;
+Var
+  C : TIntegerComponent3;
+
+begin
+  TestTIntegerComponent3;
+  C:=TIntegerComponent3.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTIntegerComponent3',C.Name);
+    AssertEquals('IntProp',262144,C.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTIntegerComponent4Read;
+
+Var
+  C : TIntegerComponent4;
+
+begin
+  TestTIntegerComponent4;
+  C:=TIntegerComponent4.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTIntegerComponent4',C.Name);
+    AssertEquals('IntProp',6,C.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTIntegerComponent5Read;
+
+Var
+  C : TIntegerComponent5;
+
+begin
+  TestTIntegerComponent5;
+  C:=TIntegerComponent5.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTIntegerComponent5',C.Name);
+    AssertEquals('IntProp',5,C.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64ComponentRead;
+
+Var
+  C : TInt64Component;
+
+begin
+  TestTInt64Component;
+  C:=TInt64Component.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component',C.Name);
+    AssertEquals('Int64Prop',4,C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64Component2Read;
+
+Var
+  C : TInt64Component2;
+
+begin
+  TestTInt64Component2;
+  C:=TInt64Component2.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component2',C.Name);
+    AssertEquals('Int64Prop',2 shl 9,C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64Component3Read;
+
+Var
+  C : TInt64Component3;
+
+begin
+  TestTInt64Component3;
+  C:=TInt64Component3.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component3',C.Name);
+    AssertEquals('Int64Prop',2 shl 17,C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64Component4Read;
+
+Var
+  C : TInt64Component4;
+
+begin
+  TestTInt64Component4;
+  C:=TInt64Component4.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component4',C.Name);
+    AssertEquals('Int64Prop',NativeInt(MaxInt)+NativeInt(2 shl 14),C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64Component5Read;
+
+Var
+  C : TInt64Component5;
+
+begin
+  TestTInt64Component5;
+  C:=TInt64Component5.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component5',C.Name);
+    // Not written, so zero remains
+    AssertEquals('Int64Prop',0,C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTInt64Component6Read;
+Var
+  C : TInt64Component6;
+
+begin
+  TestTInt64Component6;
+  C:=TInt64Component6.Create(Nil);
+  Try
+    C.Int64Prop:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTInt64Component6',C.Name);
+    AssertEquals('Int64Prop',8,C.Int64Prop);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTStringComponentRead;
+
+Var
+  C : TStringComponent;
+
+begin
+  TestTStringComponent;
+  C:=TStringComponent.Create(Nil);
+  Try
+    C.StringProp:='';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTStringComponent',C.Name);
+    AssertEquals('StringProp','A string',C.StringProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTStringComponent2Read;
+
+Var
+  C : TStringComponent2;
+
+begin
+  TestTStringComponent2;
+  C:=TStringComponent2.Create(Nil);
+  Try
+    C.StringProp:='abc';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTStringComponent2',C.Name);
+    AssertEquals('StringProp','abc',C.StringProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTWideStringComponentRead;
+
+Var
+  C : TWideStringComponent;
+
+begin
+  TestTWideStringComponent;
+  C:=TWideStringComponent.Create(Nil);
+  Try
+    C.WideStringProp:='abc';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTWideStringComponent',C.Name);
+    AssertEquals('WideStringProp','Some WideString',C.WideStringProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTWideStringComponent2Read;
+Var
+  C : TWideStringComponent2;
+
+begin
+  TestTWideStringComponent2;
+  C:=TWideStringComponent2.Create(Nil);
+  Try
+    C.WideStringProp:='abc';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTWideStringComponent2',C.Name);
+    AssertEquals('WideStringProp','abc',C.WideStringProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTSingleComponentRead;
+
+Var
+  C : TSingleComponent;
+
+begin
+  TestTSingleComponent;
+  C:=TSingleComponent.Create(Nil);
+  Try
+    C.SingleProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTSingleComponent',C.Name);
+    AssertEquals('SingleProp',1.23,C.SingleProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTDoubleComponentRead;
+
+Var
+  C : TDoubleComponent;
+
+begin
+  TestTDoubleComponent;
+  C:=TDoubleComponent.Create(Nil);
+  Try
+    C.DoubleProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTDoubleComponent',C.Name);
+    AssertEquals('DoubleProp',2.34,C.DoubleProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTExtendedComponentRead;
+
+Var
+  C : TExtendedComponent;
+
+begin
+  TestTExtendedComponent;
+  C:=TExtendedComponent.Create(Nil);
+  Try
+    C.ExtendedProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTExtendedComponent',C.Name);
+    AssertEquals('ExtendedProp',3.45,C.ExtendedProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCurrencyComponentRead;
+
+Var
+  C : TCurrencyComponent;
+
+begin
+  TestTCurrencyComponent;
+  C:=TCurrencyComponent.Create(Nil);
+  Try
+    C.CurrencyProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCurrencyComponent',C.Name);
+    AssertEquals('CurrencyProp',5.67,C.CurrencyProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTDateTimeComponentRead;
+
+Var
+  C : TDateTimeComponent;
+
+begin
+  TestTDateTimeComponent;
+  C:=TDateTimeComponent.Create(Nil);
+  Try
+    C.DateTimeProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTDateTimeComponent',C.Name);
+    AssertEquals('DateTimeProp',35278.00,C.DateTimeProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTDateTimeComponent2Read;
+
+Var
+  C : TDateTimeComponent2;
+
+begin
+  TestTDateTimeComponent2;
+  C:=TDateTimeComponent2.Create(Nil);
+  Try
+    C.DateTimeProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTDateTimeComponent2',C.Name);
+    AssertEquals('DateTimeProp',0.97,C.DateTimeProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTDateTimeComponent3Read;
+Var
+  C : TDateTimeComponent3;
+
+begin
+  TestTDateTimeComponent3;
+  C:=TDateTimeComponent3.Create(Nil);
+  Try
+    C.DateTimeProp:=0;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTDateTimeComponent3',C.Name);
+    AssertEquals('DateTimeProp',35278.97,C.DateTimeProp,0.01);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEnumComponentRead;
+
+Var
+  C : TEnumComponent;
+
+begin
+  TestTEnumComponent;
+  C:=TEnumComponent.Create(Nil);
+  Try
+    C.Dice:=One;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEnumComponent',C.Name);
+    AssertTrue('Dice',four=C.Dice);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEnumComponent2Read;
+
+Var
+  C : TEnumComponent2;
+
+begin
+  TestTEnumComponent2;
+  C:=TEnumComponent2.Create(Nil);
+  Try
+    C.Dice:=Three;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEnumComponent2',C.Name);
+    // Stream does  a value
+    AssertTrue('Dice',One=C.Dice);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEnumComponent3Read;
+
+Var
+  C : TEnumComponent3;
+
+begin
+  TestTEnumComponent3;
+  C:=TEnumComponent3.Create(Nil);
+  Try
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEnumComponent3',C.Name);
+    // Stream does not contain a value
+    AssertTrue('Dice',Three=C.Dice);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEnumComponent4Read;
+
+Var
+  C : TEnumComponent4;
+
+begin
+  TestTEnumComponent4;
+  C:=TEnumComponent4.Create(Nil);
+  Try
+    C.Dice:=six;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEnumComponent4',C.Name);
+    // Stream does not contain a value
+    AssertTrue('Dice',Six=C.Dice);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTEnumComponent5Read;
+Var
+  C : TEnumComponent5;
+
+begin
+  TestTEnumComponent5;
+  C:=TEnumComponent5.Create(Nil);
+  Try
+    C.Dice:=six;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTEnumComponent5',C.Name);
+    // Stream does not contain a value
+    AssertTrue('Dice',Six=C.Dice);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTSetComponentRead;
+
+Var
+  C : TSetComponent;
+
+begin
+  TestTSetComponent;
+  C:=TSetComponent.Create(Nil);
+  Try
+    C.Throw:=[];
+    LoadFromStream(C);
+    AssertEquals('Name','TestTSetComponent',C.Name);
+    AssertTrue('Throw',[two,five]=C.Throw);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTSetComponent2Read;
+
+Var
+  C : TSetComponent2;
+
+begin
+  TestTSetComponent2;
+  C:=TSetComponent2.Create(Nil);
+  Try
+    C.Throw:=[one,six];
+    LoadFromStream(C);
+    AssertEquals('Name','TestTSetComponent2',C.Name);
+    // Nothing was streamed
+    AssertTrue('Throw',[one,six]=C.Throw);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTSetComponent3Read;
+
+Var
+  C : TSetComponent3;
+
+begin
+  TestTSetComponent3;
+  C:=TSetComponent3.Create(Nil);
+  Try
+    C.Throw:=[two,six];
+    LoadFromStream(C);
+    AssertEquals('Name','TestTSetComponent3',C.Name);
+    // Nothing was streamed
+    AssertTrue('Throw',[one,four]=C.Throw);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTSetComponent4Read;
+
+Var
+  C : TSetComponent4;
+
+begin
+  TestTSetComponent4;
+  C:=TSetComponent4.Create(Nil);
+  Try
+    C.Throw:=[two,six];
+    LoadFromStream(C);
+    AssertEquals('Name','TestTSetComponent4',C.Name);
+    // Nothing was streamed
+    AssertTrue('Throw',[two,six]=C.Throw);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTMultipleComponentRead;
+Var
+  C : TMultipleComponent;
+
+begin
+  TestTMultipleComponent;
+  C:=TMultipleComponent.Create(Nil);
+  Try
+    c.IntProp:=23;
+    C.Dice:=six;
+    C.CurrencyProp:=12.3;
+    C.StringProp:='abc';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTMultipleComponent',C.Name);
+    AssertEquals('IntProp',1,C.IntProp);
+    AssertEquals('StringProp','A String',C.StringProp);
+    AssertEquals('CurrencyProp',2.3,C.CurrencyProp,0.1);
+    AssertTrue('Dice',two=C.Dice);
+    AssertTrue('Throw',[three,four]=C.Throw);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTPersistentComponentRead;
+
+Var
+  C : TPersistentComponent;
+
+begin
+  TestTPersistentComponent;
+  C:=TPersistentComponent.Create(Nil);
+  Try
+    C.Persist.AInteger:=36;
+    C.Persist.AString:='nono';
+    LoadFromStream(C);
+    AssertEquals('Name','TestTPersistentComponent',C.Name);
+    AssertEquals('Persist.AInteger',3,C.Persist.AInteger);
+    AssertEquals('Persist.AString','A persistent string',C.Persist.AString);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCollectionComponentRead;
+
+Var
+  C : TCollectionComponent;
+
+begin
+  TestTCollectionComponent;
+  C:=TCollectionComponent.Create(Nil);
+  Try
+    C.Coll.Add;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCollectionComponent',C.Name);
+    // If the stream does not have a collection, it does not get cleared
+    AssertEquals('Coll count',1,C.Coll.Count);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCollectionComponent2Read;
+
+Var
+  C : TCollectionComponent2;
+
+begin
+  TestTCollectionComponent2;
+  C:=TCollectionComponent2.Create(Nil);
+  Try
+    C.Coll.Add;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCollectionComponent2',C.Name);
+    AssertEquals('Coll count',3,C.Coll.Count);
+    AssertEquals('Correct class type',TTestItem,C.Coll.Items[0].ClassType);
+    AssertEquals('Coll 0 Property','First',TTestItem(C.Coll.items[0]).StrProp);
+    AssertEquals('Coll 1 Property','Second',TTestItem(C.Coll.Items[1]).StrProp);
+    AssertEquals('Coll 2 Property','Third',TTestItem(C.Coll.Items[2]).StrProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCollectionComponent3Read;
+
+Var
+  C : TCollectionComponent3;
+
+begin
+  TestTCollectionComponent3;
+  C:=TCollectionComponent3.Create(Nil);
+  Try
+    C.Coll.Add;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCollectionComponent3',C.Name);
+    AssertEquals('Coll count',3,C.Coll.Count);
+    AssertEquals('Correct class type',TTestItem,C.Coll.Items[0].ClassType);
+    AssertEquals('Coll 0 Property','First',TTestItem(C.Coll.items[0]).StrProp);
+    AssertEquals('Coll 1 Property','',TTestItem(C.Coll.Items[1]).StrProp);
+    AssertEquals('Coll 2 Property','Third',TTestItem(C.Coll.Items[2]).StrProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCollectionComponent4Read;
+
+Var
+  C : TCollectionComponent4;
+
+begin
+  TestTCollectionComponent4;
+  C:=TCollectionComponent4.Create(Nil);
+  Try
+    C.Coll.Add;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCollectionComponent4',C.Name);
+    AssertEquals('Coll count',1,C.Coll.Count);
+    AssertEquals('Correct class type',TTestItem,C.Coll.Items[0].ClassType);
+    AssertEquals('Coll 0 Property','Something',TTestItem(C.Coll.items[0]).StrProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTCollectionComponent5Read;
+
+Var
+  C : TCollectionComponent5;
+
+begin
+  TestTCollectionComponent5;
+  C:=TCollectionComponent5.Create(Nil);
+  Try
+    C.Coll.Add;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTCollectionComponent5',C.Name);
+    AssertEquals('Coll count',2,C.Coll.Count);
+    AssertEquals('Correct class type',TTest2Item,C.Coll.Items[0].ClassType);
+    AssertEquals('Coll 0 Property 1','Something',TTest2Item(C.Coll.items[0]).StrProp1);
+    AssertEquals('Coll 0 Property 2','Otherthing',TTest2Item(C.Coll.items[0]).StrProp2);
+    AssertEquals('Coll 1 property 1','Something 2',TTest2Item(C.Coll.items[1]).StrProp1);
+    AssertEquals('Coll 1 property 2','Otherthing 2',TTest2Item(C.Coll.items[1]).StrProp2);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTOwnedComponentRead;
+
+Var
+  C : TOwnedComponent;
+  C2 : TComponent;
+begin
+  TestTOwnedComponent;
+  C:=TOwnedComponent.Create(Nil);
+  try
+    C2:=C.CompProp;
+    C.CompProp:=nil;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTOwnedComponent',C.Name);
+    AssertEquals('ComponentCount',1,C.ComponentCount);
+    AssertSame('ComponentCount',C2,C.CompProp);
+  finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTStreamedOwnedComponentRead;
+Var
+  C : TStreamedOwnedComponent;
+
+begin
+  TestTStreamedOwnedComponent;
+  C:=TStreamedOwnedComponent.Create(Nil);
+  Try
+    C.Sub.Free;
+    C.Sub:=Nil;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTStreamedOwnedComponent',C.Name);
+    AssertNotNull('Have sub',C.Sub);
+    AssertEquals('Correct class',TIntegerComponent,C.Sub.ClassType);
+    AssertEquals('Name','Sub',C.Sub.Name);
+    AssertEquals('Name',3,C.Sub.IntProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+procedure TTestComponentStream.TestTStreamedOwnedComponentsRead;
+Var
+  C : TStreamedOwnedComponents;
+
+begin
+  TestTStreamedOwnedComponents;
+  C:=TStreamedOwnedComponents.Create(Nil);
+  Try
+    C.SubA.Free;
+    C.SubA:=Nil;
+    C.SubB.Free;
+    C.SubB:=Nil;
+    LoadFromStream(C);
+    AssertEquals('Name','TestTStreamedOwnedComponents',C.Name);
+    AssertNotNull('Have sub A',C.SubA);
+    AssertEquals('Correct sub A class',TIntegerComponent,C.SubA.ClassType);
+    AssertEquals('Name','SubA',C.SubA.Name);
+    AssertEquals('Name',3,C.SubA.IntProp);
+    AssertNotNull('Have sub B',C.SubB);
+    AssertEquals('Correct sub B class',TStringComponent,C.SubB.ClassType);
+    AssertEquals('Name','SubB',C.SubB.Name);
+    AssertEquals('Name','A string',C.SubB.StringProp);
+  Finally
+    C.Free;
+  end;
+end;
+
+Procedure TTestComponentStream.TestTIntegerComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TIntegerComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent2');
+    ExpectBareString('TestTIntegerComponent2');
+    ExpectBareString('IntProp');
+    ExpectInteger(1024);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTIntegerComponent3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TIntegerComponent3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent3');
+    ExpectBareString('TestTIntegerComponent3');
+    ExpectBareString('IntProp');
+    ExpectInteger(262144);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTIntegerComponent4;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TIntegerComponent4.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent4');
+    ExpectBareString('TestTIntegerComponent4');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTIntegerComponent5;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TIntegerComponent5.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent5');
+    ExpectBareString('TestTIntegerComponent5');
+    ExpectBareString('IntProp');
+    ExpectInteger(5);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component');
+    ExpectBareString('TestTInt64Component');
+    ExpectBareString('Int64Prop');
+    ExpectInteger(4);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component2');
+    ExpectBareString('TestTInt64Component2');
+    ExpectBareString('Int64Prop');
+    ExpectInteger(1024);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component3');
+    ExpectBareString('TestTInt64Component3');
+    ExpectBareString('Int64Prop');
+    ExpectInteger(262144);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component4;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component4.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component4');
+    ExpectBareString('TestTInt64Component4');
+    ExpectBareString('Int64Prop');
+    ExpectInt64(2147516415{     2147745791});
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component5;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component5.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component5');
+    ExpectBareString('TestTInt64Component5');
+//    ExpectBareString('Int64Prop');
+//    ExpectInteger(7);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTInt64Component6;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TInt64Component6.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TInt64Component6');
+    ExpectBareString('TestTInt64Component6');
+    ExpectBareString('Int64Prop');
+    ExpectInteger(8);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTStringComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TStringComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TStringComponent');
+    ExpectBareString('TestTStringComponent');
+    ExpectBareString('StringProp');
+    ExpectString('A string');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTStringComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TStringComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TStringComponent2');
+    ExpectBareString('TestTStringComponent2');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTWideStringComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TWideStringComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TWideStringComponent');
+    ExpectBareString('TestTWideStringComponent');
+    ExpectBareString('WideStringProp');
+    ExpectString('Some WideString');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTWideStringComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TWideStringComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TWideStringComponent2');
+    ExpectBareString('TestTWideStringComponent2');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTSingleComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TSingleComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TSingleComponent');
+    ExpectBareString('TestTSingleComponent');
+    ExpectBareString('SingleProp');
+    ExpectExtended(1.23);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTDoubleComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TDoubleComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TDoubleComponent');
+    ExpectBareString('TestTDoubleComponent');
+    ExpectBareString('DoubleProp');
+    ExpectExtended(2.34);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTExtendedComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TExtendedComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TExtendedComponent');
+    ExpectBareString('TestTExtendedComponent');
+    ExpectBareString('ExtendedProp');
+    ExpectExtended(3.45);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+(*
+Procedure TTestComponentStream.TestTCompComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCompComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCompComponent');
+    ExpectBareString('TestTCompComponent');
+    ExpectBareString('ExtendedProp');
+    ExpectExtended(5.00);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+    end;
+end;
+*)
+
+Procedure TTestComponentStream.TestTCurrencyComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCurrencyComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCurrencyComponent');
+    ExpectBareString('TestTCurrencyComponent');
+    ExpectBareString('CurrencyProp');
+    ExpectInteger(56700);
+// Natively, this is:
+//    ExpectExtended(5.67);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTDateTimeComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TDateTimeComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TDateTimeComponent');
+    ExpectBareString('TestTDateTimeComponent');
+    ExpectBareString('DateTimeProp');
+    ExpectExtended(35278.00);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTDateTimeComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TDateTimeComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TDateTimeComponent2');
+    ExpectBareString('TestTDateTimeComponent2');
+    ExpectBareString('DateTimeProp');
+    ExpectExtended(0.97);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTDateTimeComponent3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TDateTimeComponent3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TDateTimeComponent3');
+    ExpectBareString('TestTDateTimeComponent3');
+    ExpectBareString('DateTimeProp');
+    ExpectExtended(35278.97);
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTEnumComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEnumComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEnumComponent');
+    ExpectBareString('TestTEnumComponent');
+    ExpectBareString('Dice');
+    ExpectIdent('four');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTEnumComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEnumComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEnumComponent2');
+    ExpectBareString('TestTEnumComponent2');
+{$ifndef FPC}
+    // FPC does not stream an undeclared default value, it assumes the
+    // 0-the value is the default.
+    ExpectBareString('Dice');
+    ExpectIdent('one');
+{$endif FPC}
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTEnumComponent3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEnumComponent3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEnumComponent3');
+    ExpectBareString('TestTEnumComponent3');
+    ExpectBareString('Dice');
+    ExpectIdent('three');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTEnumComponent4;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEnumComponent4.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEnumComponent4');
+    ExpectBareString('TestTEnumComponent4');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+Procedure TTestComponentStream.TestTEnumComponent5;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TEnumComponent5.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TEnumComponent5');
+    ExpectBareString('TestTEnumComponent5');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTSetComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TSetComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TSetComponent');
+    ExpectBareString('TestTSetComponent');
+    ExpectBareString('Throw');
+    ExpectValue(vaSet);
+    ExpectBareString('two');
+    ExpectBareString('five');
+    ExpectBareString('');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTSetComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TSetComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TSetComponent2');
+    ExpectBareString('TestTSetComponent2');
+{$ifdef delphi}
+    // Same as for sets: a set with undeclared default is regarded as
+    // A set with default [], and is not streamed if it is empty.
+    ExpectBareString('Throw');
+    ExpectValue(vaSet);
+    ExpectBareString('');
+{$endif delphi}
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTSetComponent3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TSetComponent3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TSetComponent3');
+    ExpectBareString('TestTSetComponent3');
+    ExpectBareString('Throw');
+    ExpectValue(vaSet);
+    ExpectBareString('one');
+    ExpectBareString('four');
+    ExpectBareString('');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTSetComponent4;
+
+Var
+  C : TComponent;
+
+begin
+  // Writeln('Start test');
+  C:=TSetComponent4.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TSetComponent4');
+    ExpectBareString('TestTSetComponent4');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTMultipleComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TMultipleComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TMultipleComponent');
+    ExpectBareString('TestTMultipleComponent');
+    ExpectBareString('IntProp');
+    ExpectInteger(1);
+    ExpectBareString('StringProp');
+    ExpectString('A String');
+    ExpectBareString('CurrencyProp');
+    ExpectInteger(23000);
+//    ExpectExtended(2.30);
+    ExpectBareString('Dice');
+    ExpectIdent('two');
+    ExpectBareString('Throw');
+    ExpectValue(vaSet);
+    ExpectBareString('three');
+    ExpectBareString('four');
+    ExpectBareString('');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTPersistentComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TPersistentComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TPersistentComponent');
+    ExpectBareString('TestTPersistentComponent');
+    ExpectBareString('Persist.AInteger');
+    ExpectInteger(3);
+    ExpectBareString('Persist.AString');
+    ExpectString('A persistent string');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTCollectionComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCollectionComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCollectionComponent');
+    ExpectBareString('TestTCollectionComponent');
+    ExpectBareString('Coll');
+    ExpectValue(vaCollection);
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTCollectionComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCollectionComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCollectionComponent2');
+    ExpectBareString('TestTCollectionComponent2');
+    ExpectBareString('Coll');
+    ExpectValue(vaCollection);
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('First');
+    ExpectEndOfList;
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('Second');
+    ExpectEndOfList;
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('Third');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTCollectionComponent3;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCollectionComponent3.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCollectionComponent3');
+    ExpectBareString('TestTCollectionComponent3');
+    ExpectBareString('Coll');
+    ExpectValue(vaCollection);
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('First');
+    ExpectEndOfList;
+    ExpectValue(vaList);
+    ExpectEndOfList;
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('Third');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTCollectionComponent4;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCollectionComponent4.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCollectionComponent4');
+    ExpectBareString('TestTCollectionComponent4');
+    ExpectBareString('Coll');
+    ExpectValue(vaCollection);
+    ExpectValue(vaList);
+    ExpectBareString('StrProp');
+    ExpectString('Something');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+Procedure TTestComponentStream.TestTCollectionComponent5;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TCollectionComponent5.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TCollectionComponent5');
+    ExpectBareString('TestTCollectionComponent5');
+    ExpectBareString('Coll');
+    ExpectValue(vaCollection);
+    ExpectValue(vaList);
+    ExpectBareString('StrProp1');
+    ExpectString('Something');
+    ExpectBareString('StrProp2');
+    ExpectString('Otherthing');
+    ExpectEndOfList;
+    ExpectValue(vaList);
+    ExpectBareString('StrProp1');
+    ExpectString('Something 2');
+    ExpectBareString('StrProp2');
+    ExpectString('Otherthing 2');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTOwnedComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TOwnedComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TOwnedComponent');
+    ExpectBareString('TestTOwnedComponent');
+    ExpectBareString('CompProp');
+    ExpectIdent('SubComponent');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTStreamedOwnedComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TStreamedOwnedComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TStreamedOwnedComponent');
+    ExpectBareString('TestTStreamedOwnedComponent');
+    ExpectEndOfList;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent');
+    ExpectBareString('Sub');
+    ExpectBareString('IntProp');
+    ExpectInteger(3);
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfStream;
+  Finally
+    C.Free;
+  end;
+end;
+
+Procedure TTestComponentStream.TestTStreamedOwnedComponents;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TStreamedOwnedComponents.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TStreamedOwnedComponents');
+    ExpectBareString('TestTStreamedOwnedComponents');
+    ExpectEndOfList;
+    ExpectFlags([],0);
+    ExpectBareString('TIntegerComponent');
+    ExpectBareString('SubA');
+    ExpectBareString('IntProp');
+    ExpectInteger(3);
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectFlags([],0);
+    ExpectBareString('TStringComponent');
+    ExpectBareString('SubB');
+    ExpectBareString('StringProp');
+    ExpectString('A string');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfStream;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTMethodComponent;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TMethodComponent.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TMethodComponent');
+    ExpectBareString('TestTMethodComponent');
+    ExpectBareString('MethodProp');
+    ExpectIdent('MyMethod');
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+Procedure TTestComponentStream.TestTMethodComponent2;
+
+Var
+  C : TComponent;
+
+begin
+  C:=TMethodComponent2.Create(Nil);
+  Try
+    SaveToStream(C);
+    ExpectSignature;
+    ExpectFlags([],0);
+    ExpectBareString('TMethodComponent2');
+    ExpectBareString('TestTMethodComponent2');
+    ExpectEndOfList;
+    ExpectFlags([],0);
+    ExpectBareString('TMethodComponent');
+    ExpectBareString('AComponent');
+    ExpectBareString('MethodProp');
+    ExpectIdent('MyMethod2');
+    ExpectEndOfList;
+    ExpectEndOfList;
+    ExpectEndOfList;
+  Finally
+    C.Free;
+  end;
+end;
+
+
+
+Procedure TTestCollectionStream.CompareColl(CA,CB : TMyColl);
+
+Var
+  I : Integer;
+
+begin
+  AssertEquals('Counts differ: %d %d',CA.Count,CB.Count);
+  For I:=0 to CA.Count-1 do
+    begin
+    AssertEquals(Format('Nr property of element %d equals',[I]),CA[i].Nr,CB[i].Nr);
+    AssertEquals(Format('Str property of element %d equals',[I]),CA[i].Str,CB[i].Str);
+    end;
+end;
+
+Function TTestCollectionStream.EmptyComp : TCollComp;
+
+begin
+  Result:=TCollComp.Create(Nil);
+end;
+
+Function TTestCollectionStream.CreateColl(Anr : Integer) : TCollComp;
+
+Var
+  I : Integer;
+  T : TMyItem;
+
+begin
+  Result:=EmptyComp;
+  Result.Name:='C'+IntToStr(Anr);
+  For I:=0 to ANr-1 do
+    begin
+    T:=Result.MyColl.Add as TMyItem;
+    T.Nr:=I; // not I+1, so the default value gets tested too
+    T.Str:=IntToStr(I+1);
+    end;
+end;
+
+Procedure TTestCollectionStream.TestEmpty;
+
+Var
+ CA,CB : TCollComp;
+
+begin
+  CA:=CreateColl(0);
+  try
+    CB:=EmptyComp;
+    Try
+      CB.FromStream(CA.ToStream);
+      CompareColl(CA.MyColl,CB.MyColl);
+    Finally
+      CB.Free;
+    end;
+  Finally
+    CA.Free;
+  end;
+end;
+
+Procedure TTestCollectionStream.TestNr(ACount : Integer);
+
+Var
+ CA,CB : TCollComp;
+
+begin
+  CA:=CreateColl(ACount);
+  try
+    CB:=EmptyComp;
+    Try
+      CB.FromStream(CA.ToStream);
+      CompareColl(CA.MyColl,CB.MyColl);
+    Finally
+      CB.Free;
+    end;
+  Finally
+    CA.Free;
+  end;
+end;
+
+Procedure TTestCollectionStream.TestClear;
+
+Var
+ CA,CB : TCollComp;
+
+begin
+  CA:=CreateColl(3);
+  try
+    CB:=CreateColl(1);
+    CB.Name:='';
+    Try
+      // CB collection should be cleared before loading.
+      CB.FromStream(CA.ToStream);
+      CompareColl(CA.MyColl,CB.MyColl);
+    Finally
+      CB.Free;
+    end;
+  Finally
+    CA.Free;
+  end;
+end;
+
+Procedure TTestCollectionStream.Test1;
+
+begin
+  TestNr(1);
+end;
+
+Procedure TTestCollectionStream.Test2;
+
+begin
+  TestNr(2);
+end;
+
+Procedure TTestCollectionStream.Test3;
+
+begin
+  TestNr(3);
+end;
+
+begin
+  RegisterTests([TTestComponentStream,TTestCollectionStream]);
+end.

+ 760 - 0
test/tcstream.pp

@@ -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 - 0
test/tcstreaming.pp

@@ -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 - 0
test/testrtl.html

@@ -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 - 0
test/testrtl.lpi

@@ -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 - 0
test/testrtl.lpr

@@ -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.