Browse Source

* exit with ExitCode<>0 if any error occurs

git-svn-id: trunk@7158 -
pierre 18 years ago
parent
commit
bcfecca1b3

+ 1 - 0
.gitattributes

@@ -7025,6 +7025,7 @@ tests/test/units/system/tval1.pp -text
 tests/test/units/system/tval2.pp -text
 tests/test/units/system/tval3.pp -text
 tests/test/units/system/tval4.pp -text
+tests/test/units/system/tvalc.pp -text
 tests/test/units/sysutils/execansi.pp svneol=native#text/plain
 tests/test/units/sysutils/execedbya.pp svneol=native#text/plain
 tests/test/units/sysutils/extractquote.pp svneol=native#text/plain

+ 0 - 56
tests/test/units/system/tval.inc

@@ -6,62 +6,6 @@
   all basic integer types }
 
 
-
-const
-  HasErrors : boolean = false;
-  Silent : boolean = true;
-  CheckVal : boolean = true;
-  SuccessCount : longint = 0;
-  FailCount : longint = 0;
-
-type
-  TCharSet = set of char;
-const
-  ValidNumeralsBase2 : TCHarSet = ['0'..'1'];
-  ValidNumeralsBase8 : TCHarSet = ['0'..'7'];
-  ValidNumeralsBase10 : TCHarSet = ['0'..'9'];
-  ValidNumeralsBase16 : TCHarSet = ['0'..'9','a'..'f','A'..'F'];
-  SpecialCharsFirst : TCharSet = [' ',#9,'x','X','$','&','%','+','-'];
-  SpecialCharsSecond : TCharSet = [#0];
-
-type
-
-  ValTestType =
-  (ValShouldFail,
-   ValShouldSucceed,
-   ValShouldSucceedAfterRemovingTrail);
-
-
-function Display(const s : string) : string;
-var
-  res,ordval : string;
-  i : longint;
-  quoted : boolean;
-begin
-  res:='"';
-  quoted:=false;
-  for i:=1 to length(s) do
-    if ord(s[i])<32 then
-      begin
-        if quoted then
-          res:=res+'''';
-        str(ord(s[i]),ordval);
-        res:=res+'#'+ordval;
-        quoted:=false;
-      end
-    else
-      begin
-        if not quoted then
-          res:=res+'''';
-        quoted:=true;
-        res:=res+s[i];
-      end;
-  if quoted then
-    res:=res+'''';
-  res:=res+'"';
-  Display:=res;
-end;
-
 procedure TestVal(comment,s : string; ExpectedRes : ValTestType; expected : IntegerType);
 var
   i : IntegerType;

+ 11 - 1
tests/test/units/system/tval.pp

@@ -9,13 +9,23 @@ uses
   { int64 type, short string }
   tval3,
   { uint64 type, short string }
-  tval4;
+  tval4,
+  { common variables and functions }
+  tvalc;
 
 
 
 begin
+  if (paramcount>0) and
+     (paramstr(1)='verbose') then
+       silent:=false;
   TestAllVal1;
   TestAllVal2;
   TestAllVal3;
   TestAllVal4;
+  if HasErrors then
+    begin
+      Writeln('Test tval failed');
+      Halt(1);
+    end;
 end.

+ 3 - 3
tests/test/units/system/tval1.pp

@@ -9,6 +9,9 @@ function TestAllVal1 : boolean;
 
 implementation
 
+uses
+  tvalc;
+
 type
   IntegerType = longint;
 
@@ -17,9 +20,6 @@ type
 
 function TestAllVal1 : boolean;
 begin
-  if (paramcount>0) and
-     (paramstr(1)='verbose') then
-       silent:=false;
   Writeln('Test val for longint type');
   TestAllVal1:=TestAll;
 end;

+ 3 - 3
tests/test/units/system/tval2.pp

@@ -9,6 +9,9 @@ function TestAllval2 : boolean;
 
 implementation
 
+uses
+  tvalc;
+
 type
   IntegerType = dword;
 
@@ -17,9 +20,6 @@ type
 
 function TestAllval2 : boolean;
 begin
-  if (paramcount>0) and
-     (paramstr(1)='verbose') then
-       silent:=false;
   Writeln('Test val for dword type');
   TestAllval2:=TestAll;
 end;

+ 3 - 3
tests/test/units/system/tval3.pp

@@ -9,6 +9,9 @@ function TestAllval3 : boolean;
 
 implementation
 
+uses
+  tvalc;
+
 type
   IntegerType = int64;
 
@@ -17,9 +20,6 @@ type
 
 function TestAllval3 : boolean;
 begin
-  if (paramcount>0) and
-     (paramstr(1)='verbose') then
-       silent:=false;
   Writeln('Test val for int64 type');
   TestAllval3:=TestAll;
 end;

+ 3 - 3
tests/test/units/system/tval4.pp

@@ -9,6 +9,9 @@ function TestAllval4 : boolean;
 
 implementation
 
+uses
+  tvalc;
+
 type
   IntegerType = qword;
 
@@ -17,9 +20,6 @@ type
 
 function TestAllval4 : boolean;
 begin
-  if (paramcount>0) and
-     (paramstr(1)='verbose') then
-       silent:=false;
   Writeln('Test val for qword type');
   TestAllval4:=TestAll;
 end;

+ 63 - 0
tests/test/units/system/tvalc.pp

@@ -0,0 +1,63 @@
+unit tvalc;
+
+interface
+const
+  HasErrors : boolean = false;
+  Silent : boolean = true;
+  CheckVal : boolean = true;
+  SuccessCount : longint = 0;
+  FailCount : longint = 0;
+
+type
+  TCharSet = set of char;
+const
+  ValidNumeralsBase2 : TCHarSet = ['0'..'1'];
+  ValidNumeralsBase8 : TCHarSet = ['0'..'7'];
+  ValidNumeralsBase10 : TCHarSet = ['0'..'9'];
+  ValidNumeralsBase16 : TCHarSet = ['0'..'9','a'..'f','A'..'F'];
+  SpecialCharsFirst : TCharSet = [' ',#9,'x','X','$','&','%','+','-'];
+  SpecialCharsSecond : TCharSet = [#0];
+
+type
+
+  ValTestType =
+  (ValShouldFail,
+   ValShouldSucceed,
+   ValShouldSucceedAfterRemovingTrail);
+
+
+function Display(const s : string) : string;
+
+implementation
+
+function Display(const s : string) : string;
+var
+  res,ordval : string;
+  i : longint;
+  quoted : boolean;
+begin
+  res:='"';
+  quoted:=false;
+  for i:=1 to length(s) do
+    if ord(s[i])<32 then
+      begin
+        if quoted then
+          res:=res+'''';
+        str(ord(s[i]),ordval);
+        res:=res+'#'+ordval;
+        quoted:=false;
+      end
+    else
+      begin
+        if not quoted then
+          res:=res+'''';
+        quoted:=true;
+        res:=res+s[i];
+      end;
+  if quoted then
+    res:=res+'''';
+  res:=res+'"';
+  Display:=res;
+end;
+
+end.