fpc/tests/test/jvm/tvalc.pp
Jonas Maebe 71068ae7eb * made the tests Android-compatible (use the androidr14 unit instead
of the jdk15 unit in that case)
  * adjusted testall.sh script so it can also be used to test class
    files compiled for Android (still with the JVM though)

git-svn-id: branches/jvmbackend@19835 -
2011-12-12 20:34:02 +00:00

75 lines
1.4 KiB
ObjectPascal

unit tvalc;
interface
{$ifdef cpujvm}
uses
{$ifdef java}jdk15{$else}androidr14{$endif};
{$macro on}
{$define write:=JLSystem.fout.print}
{$define writeln:=JLSystem.fout.println}
{$endif}
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.