Browse Source

fcl-json: clean up, updated TestStrings

mattias 3 years ago
parent
commit
a7951612da

+ 0 - 7
packages/fcl-json/src/fpjsontopas.pp

@@ -731,9 +731,6 @@ end;
 
 procedure TJSONToPascal.GenerateClearArray(M,IM : TPropertyMapItem);
 
-Var
-  IP : String;
-
 begin
   AddLn('');
   AddLn('Procedure ClearArray(Var anArray : %s);',[M.TypeName]);
@@ -849,11 +846,9 @@ procedure TJSONToPascal.GenerateCreateObjectfpJSON(M : TPropertyMapItem);
 
 Var
   IP : String;
-  IM : TPropertyMapItem;
 
 begin
   IP:=AddToPath(M.Path,'[0]');
-  IM:=FPropertyMap.FindPath(IP);
   AddLn('');
   Indent;
   AddLn('Function CreateObject%s(AnObject : TJSONData) : %s;',[M.TypeName,M.TypeName]);
@@ -934,8 +929,6 @@ function TJSONToPascal.GenerateAssign(IM: TPropertyMapItem; AVarName, AJSONName:
 
 Var
   T : String;
-  C : Boolean;
-
 begin
   T:='';
   Case LowerCase(IM.TypeName) of

+ 2 - 2
packages/fcl-json/tests/jsonconftest.pas

@@ -6,7 +6,7 @@ unit jsonconftest;
 interface
 
 uses
-  Classes, SysUtils, fpcunit, testutils, testregistry, jsonconf;
+  Classes, SysUtils, fpcunit, testregistry, jsonconf;
 
 type
 
@@ -315,7 +315,7 @@ begin
     AssertStrings('integer',L,['1']);
     C.SetValue('a',True);
     C.GetValue('a',L,'');
-    AssertStrings('integer',L,['True']);
+    AssertStrings('integer',L,['true']);
     C.SetValue('a',Int64(1));
     C.GetValue('a',L,'');
     AssertStrings('int64',L,['1']);

+ 1 - 9
packages/fcl-json/tests/tcjsontocode.pas

@@ -5,7 +5,7 @@ unit tcjsontocode;
 interface
 
 uses
-  Classes, SysUtils, fpcunit, testutils, testregistry, fpjsontopas;
+  Classes, SysUtils, fpcunit, testregistry, fpjsontopas;
 
 type
 
@@ -1495,13 +1495,8 @@ begin
 end;
 
 procedure TTestGenCode.AssertSaveArray(AElementType, AJSONtype: String; IsDelphi: Boolean = False);
-
-Var
-  DN : String;
-
 begin
   AssertUnitHeader;
-  DN:=GetDataName(IsDelphi);
   AssertArrayType('Ta',AElementType);
   AssertArraySaver('Ta',AElementType,IsDelphi);
   AssertType;
@@ -1604,9 +1599,6 @@ end;
 
 procedure TTestGenCode.TestLoadDelphiIntegerProperty;
 
-Var
-  S : String;
-
 begin
   Gen.Options:=[jpoGenerateLoad,jpoDelphiJSON];
   GenCode('{ "a" : 1234 }');

+ 14 - 12
packages/fcl-json/tests/testjson2code.lpi

@@ -1,10 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="9"/>
+    <Version Value="12"/>
     <General>
+      <Flags>
+        <CompatibilityMode Value="True"/>
+      </Flags>
       <SessionStorage Value="InProjectDir"/>
-      <MainUnit Value="0"/>
       <Title Value="testjson2code"/>
       <UseAppBundle Value="False"/>
       <ResourceType Value="res"/>
@@ -12,9 +14,6 @@
     <i18n>
       <EnableI18N LFM="False"/>
     </i18n>
-    <VersionInfo>
-      <StringTable ProductVersion=""/>
-    </VersionInfo>
     <BuildModes Count="1">
       <Item1 Name="Default" Default="True"/>
     </BuildModes>
@@ -23,28 +22,31 @@
     </PublishOptions>
     <RunParams>
       <local>
-        <FormatVersion Value="1"/>
         <CommandLineParams Value="--suite=TestLoadObjectProperty"/>
       </local>
+      <FormatVersion Value="2"/>
+      <Modes Count="1">
+        <Mode0 Name="default">
+          <local>
+            <CommandLineParams Value="--suite=TestLoadObjectProperty"/>
+          </local>
+        </Mode0>
+      </Modes>
     </RunParams>
     <RequiredPackages Count="1">
       <Item1>
         <PackageName Value="FCL"/>
       </Item1>
     </RequiredPackages>
-    <Units Count="3">
+    <Units Count="2">
       <Unit0>
         <Filename Value="testjson2code.lpr"/>
         <IsPartOfProject Value="True"/>
       </Unit0>
       <Unit1>
-        <Filename Value="tcjsontocode.pp"/>
-        <IsPartOfProject Value="True"/>
-      </Unit1>
-      <Unit2>
         <Filename Value="../src/fpjsontopas.pp"/>
         <IsPartOfProject Value="True"/>
-      </Unit2>
+      </Unit1>
     </Units>
   </ProjectOptions>
   <CompilerOptions>

+ 2 - 4
packages/fcl-json/tests/testjson2code.lpr

@@ -3,12 +3,10 @@ program testjson2code;
 {$mode objfpc}{$H+}
 
 uses
-  Classes, consoletestrunner, tcjsontocode, fpjsontopas;
+  Classes, consoletestrunner, fpjsontopas;
 
 type
 
-  { TLazTestRunner }
-
   { TMyTestRunner }
 
   TMyTestRunner = class(TTestRunner)
@@ -49,4 +47,4 @@ begin
   Application.Title := 'FPCUnit Console test runner';
   Application.Run;
   Application.Free;
-end.
+end.

+ 2 - 2
packages/fcl-json/tests/testjsonconf.lpi

@@ -35,11 +35,11 @@
     </RequiredPackages>
     <Units Count="3">
       <Unit0>
-        <Filename Value="testjsonconf.pp"/>
+        <Filename Value="testjsonconf.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit0>
       <Unit1>
-        <Filename Value="jsonconftest.pp"/>
+        <Filename Value="jsonconftest.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit1>
       <Unit2>