Ver Fonte

* Remove unused variables

git-svn-id: trunk@34538 -
michael há 9 anos atrás
pai
commit
4e39c254d2

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

@@ -406,7 +406,6 @@ Var
   PI : PPropInfo;
   PI : PPropInfo;
   TI : PTypeInfo;
   TI : PTypeInfo;
   I,J,S : Integer;
   I,J,S : Integer;
-  D : Double;
   A : TJSONArray;
   A : TJSONArray;
   JS : TJSONStringType;
   JS : TJSONStringType;
 begin
 begin
@@ -551,8 +550,6 @@ procedure TJSONDeStreamer.JSONToCollection(const JSON: TJSONData;
 Var
 Var
   I : integer;
   I : integer;
   A : TJSONArray;
   A : TJSONArray;
-  O : TJSONObject;
-
 begin
 begin
   If (JSON.JSONType=jtArray) then
   If (JSON.JSONType=jtArray) then
     A:=JSON As TJSONArray
     A:=JSON As TJSONArray
@@ -980,10 +977,6 @@ end;
 
 
 function TJSONStreamer.StreamClassProperty(const AObject: TObject): TJSONData;
 function TJSONStreamer.StreamClassProperty(const AObject: TObject): TJSONData;
 
 
-Var
-  C : TCollection;
-  I : integer;
-
 begin
 begin
   Result:=Nil;
   Result:=Nil;
   If (AObject=Nil) then
   If (AObject=Nil) then

+ 0 - 1
packages/fcl-json/src/jsonparser.pp

@@ -65,7 +65,6 @@ Resourcestring
   SErrUnexpectedEOF   = 'Unexpected EOF encountered.';
   SErrUnexpectedEOF   = 'Unexpected EOF encountered.';
   SErrUnexpectedToken = 'Unexpected token (%s) encountered.';
   SErrUnexpectedToken = 'Unexpected token (%s) encountered.';
   SErrExpectedColon   = 'Expected colon (:), got token "%s".';
   SErrExpectedColon   = 'Expected colon (:), got token "%s".';
-  SErrUnexpectedComma = 'Invalid comma encountered.';
   SErrEmptyElement = 'Empty element encountered.';
   SErrEmptyElement = 'Empty element encountered.';
   SErrExpectedElementName    = 'Expected element name, got token "%s"';
   SErrExpectedElementName    = 'Expected element name, got token "%s"';
   SExpectedCommaorBraceClose = 'Expected , or ], got token "%s".';
   SExpectedCommaorBraceClose = 'Expected , or ], got token "%s".';

+ 2 - 2
packages/fcl-json/src/jsonscanner.pp

@@ -205,10 +205,10 @@ function TJSONScanner.DoFetchToken: TJSONToken;
   end;
   end;
 
 
 var
 var
-  TokenStart, CurPos: PChar;
+  TokenStart: PChar;
   it : TJSONToken;
   it : TJSONToken;
   I : Integer;
   I : Integer;
-  OldLength, SectionLength, Index, tstart,tcol: Integer;
+  OldLength, SectionLength,  tstart,tcol: Integer;
   C : char;
   C : char;
   S : String;
   S : String;
   IsStar,EOC: Boolean;
   IsStar,EOC: Boolean;

+ 38 - 19
packages/fcl-json/tests/testjsondata.pp

@@ -19,7 +19,7 @@ unit testjsondata;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, fpcunit, testutils, testregistry, fpjson;
+  Classes, SysUtils, fpcunit, testregistry, fpjson;
 
 
 type
 type
    TMyNull     = Class(TJSONNull);
    TMyNull     = Class(TJSONNull);
@@ -204,6 +204,7 @@ type
     Procedure TestClone;
     Procedure TestClone;
     Procedure TestMyClone;
     Procedure TestMyClone;
     Procedure TestFormat;
     Procedure TestFormat;
+    Procedure TestFormatNil;
   end;
   end;
   
   
   { TTestObject }
   { TTestObject }
@@ -252,6 +253,7 @@ type
     procedure TestExtract;
     procedure TestExtract;
     Procedure TestNonExistingAccessError;
     Procedure TestNonExistingAccessError;
     Procedure TestFormat;
     Procedure TestFormat;
+    Procedure TestFormatNil;
     Procedure TestFind;
     Procedure TestFind;
   end;
   end;
 
 
@@ -1002,7 +1004,6 @@ end;
 
 
 procedure TTestJSONPath.TestDeepRecursive;
 procedure TTestJSONPath.TestDeepRecursive;
 Var
 Var
-  O : TJSONObject;
   A : TJSONArray;
   A : TJSONArray;
   D : TJSONData;
   D : TJSONData;
 begin
 begin
@@ -2563,7 +2564,6 @@ procedure TTestArray.TestAddString;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
   S : String;
   S : String;
-  F : TJSONFloat;
   
   
 begin
 begin
   S:='A string';
   S:='A string';
@@ -2585,8 +2585,6 @@ procedure TTestArray.TestAddNull;
 
 
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
-  S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
   J:=TJSonArray.Create;
   J:=TJSonArray.Create;
@@ -2720,7 +2718,6 @@ procedure TTestArray.TestInsertString;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
   S : String;
   S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
   S:='A string';
   S:='A string';
@@ -2742,8 +2739,6 @@ end;
 procedure TTestArray.TestInsertNull;
 procedure TTestArray.TestInsertNull;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
-  S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
   J:=TJSonArray.Create;
   J:=TJSonArray.Create;
@@ -2825,11 +2820,8 @@ end;
 procedure TTestArray.TestMove;
 procedure TTestArray.TestMove;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
-  S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
-  S:='A string';
   J:=TJSonArray.Create;
   J:=TJSonArray.Create;
   try
   try
     J.Add('First string');
     J.Add('First string');
@@ -2849,11 +2841,8 @@ end;
 procedure TTestArray.TestExchange;
 procedure TTestArray.TestExchange;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
-  S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
-  S:='A string';
   J:=TJSonArray.Create;
   J:=TJSonArray.Create;
   try
   try
     J.Add('First string');
     J.Add('First string');
@@ -2987,7 +2976,7 @@ end;
 
 
 procedure TTestArray.TestMyClone;
 procedure TTestArray.TestMyClone;
 Var
 Var
-  J,J2 : TMyArray;
+  J : TMyArray;
   D : TJSONData;
   D : TJSONData;
 
 
 begin
 begin
@@ -3010,7 +2999,6 @@ end;
 procedure TTestArray.TestFormat;
 procedure TTestArray.TestFormat;
 Var
 Var
   J : TJSONArray;
   J : TJSONArray;
-  I : TJSONData;
 
 
 begin
 begin
   J:=TJSonArray.Create;
   J:=TJSonArray.Create;
@@ -3033,6 +3021,23 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TTestArray.TestFormatNil;
+
+Var
+  J : TJSONArray;
+
+begin
+  J:=TJSonArray.Create;
+  try
+    J.Add(1);
+    J.Add(TJSONObject(Nil));
+    TestJSON(J,'[1, null]');
+    AssertEquals('FormatJSON, single line',J.AsJSON,J.FormatJSON([foSingleLineArray],1));
+  finally
+    J.Free;
+  end;
+end;
+
 { TTestObject }
 { TTestObject }
 
 
 procedure TTestObject.TestCreate;
 procedure TTestObject.TestCreate;
@@ -3199,7 +3204,6 @@ Const
 Var
 Var
   J : TJSONObject;
   J : TJSONObject;
   S : String;
   S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
   S:='A string';
   S:='A string';
@@ -3224,8 +3228,6 @@ Const
 
 
 Var
 Var
   J : TJSONObject;
   J : TJSONObject;
-  S : String;
-  F : TJSONFloat;
 
 
 begin
 begin
   J:=TJSonObject.Create;
   J:=TJSonObject.Create;
@@ -3482,6 +3484,23 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TTestObject.TestFormatNil;
+
+Var
+  J : TJSONObject;
+
+begin
+  J:=TJSONObject.Create;
+  try
+    J.Add('a',1);
+    J.Add('b',TJSONObject(Nil));
+    TestJSON(J,'{ "a" : 1, "b" : null }');
+    AssertEquals('FormatJSON, single line',J.AsJSON,J.FormatJSON([foSingleLineObject],1));
+  finally
+    J.Free;
+  end;
+end;
+
 procedure TTestObject.TestFind;
 procedure TTestObject.TestFind;
 
 
 Const
 Const

+ 1 - 1
packages/fcl-json/tests/testjsonparser.pp

@@ -19,7 +19,7 @@ unit testjsonparser;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, fpcunit, testutils, testregistry,fpjson,
+  Classes, SysUtils, fpcunit, testregistry,fpjson,
   jsonscanner,jsonParser,testjsondata;
   jsonscanner,jsonParser,testjsondata;
 
 
 Const
 Const

+ 1 - 8
packages/fcl-json/tests/testjsonrtti.pp

@@ -117,7 +117,6 @@ type
     FDS : TJSONDeStreamer;
     FDS : TJSONDeStreamer;
     FJD : TJSONData;
     FJD : TJSONData;
     FToFree : TObject;
     FToFree : TObject;
-    FCalled : Boolean;
     procedure DeStream(JSON: TJSONStringType; AObject: TObject);
     procedure DeStream(JSON: TJSONStringType; AObject: TObject);
     procedure DeStream(JSON: TJSONObject; AObject: TObject);
     procedure DeStream(JSON: TJSONObject; AObject: TObject);
     procedure DoDateTimeFormat;
     procedure DoDateTimeFormat;
@@ -1021,7 +1020,6 @@ procedure TTestJSONStreamer.TestCollectionProp2;
 
 
 Var
 Var
   C : TCollectionComponent;
   C : TCollectionComponent;
-  F : TJSONObject;
   A : TJSONArray;
   A : TJSONArray;
 
 
 begin
 begin
@@ -1057,8 +1055,6 @@ end;
 
 
 procedure TTestJSONStreamer.TestStringsProp1;
 procedure TTestJSONStreamer.TestStringsProp1;
 
 
-Var
-  A : TJSONArray;
 begin
 begin
   RJ.Options:=[jsoTstringsAsArray];
   RJ.Options:=[jsoTstringsAsArray];
   StreamObject(TStringsCOmponent.Create(Nil));
   StreamObject(TStringsCOmponent.Create(Nil));
@@ -1068,8 +1064,6 @@ end;
 
 
 procedure TTestJSONStreamer.TestStringsProp2;
 procedure TTestJSONStreamer.TestStringsProp2;
 
 
-Var
-  A : TJSONArray;
 begin
 begin
   StreamObject(TStringsCOmponent.Create(Nil));
   StreamObject(TStringsCOmponent.Create(Nil));
   AssertPropCount(1);
   AssertPropCount(1);
@@ -1267,7 +1261,6 @@ end;
 
 
 procedure TTestJSONStreamer.TestStringsStream4;
 procedure TTestJSONStreamer.TestStringsStream4;
 Var
 Var
-  O : TJSONObject;
   S : TStringList;
   S : TStringList;
 
 
 begin
 begin
@@ -1598,7 +1591,7 @@ begin
   AssertEquals('Variant type',VarTypeAsText(varSingle),VarTypeAsText(VarType(C.VariantProp)));
   AssertEquals('Variant type',VarTypeAsText(varSingle),VarTypeAsText(VarType(C.VariantProp)));
   StreamObject(FTofree);
   StreamObject(FTofree);
   AssertPropCount(1);
   AssertPropCount(1);
-  AssertProp('VariantProp',3.14);
+  AssertProp('VariantProp',i);
 end;
 end;
 
 
 procedure TTestJSONStreamer.TestVariantdouble;
 procedure TTestJSONStreamer.TestVariantdouble;