mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 17:49:29 +02:00

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 -
75 lines
1.4 KiB
ObjectPascal
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.
|