summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authornickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-01 13:21:24 +0000
committernickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-01 13:21:24 +0000
commitefc9f396e6322803ca30817ffbb7efa47f056254 (patch)
tree6b133633c9766e3ae8e62d8a5ac988637e662e23 /tests
parent7970081cf98f70ce91af964068a6b32f062d9b8f (diff)
parente7fde3b46193c6a3865103c7a7a82e600f787782 (diff)
downloadfpc-efc9f396e6322803ca30817ffbb7efa47f056254.tar.gz
* synchronized with trunk
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/wasm@48846 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests')
-rw-r--r--tests/test/tandorandnot1.pp34
-rw-r--r--tests/test/tmt1.pp4
-rw-r--r--tests/test/units/strutils/tboyer.pp79
-rw-r--r--tests/utils/dotest.pp12
-rw-r--r--tests/webtbf/tw38504.pp11
-rw-r--r--tests/webtbf/tw38504b.pp11
-rw-r--r--tests/webtbs/tw28713.pp7
-rw-r--r--tests/webtbs/tw36250.pp15
-rw-r--r--tests/webtbs/tw38497.pp24
-rw-r--r--tests/webtbs/tw38527.pp15
-rw-r--r--tests/webtbs/tw8177.pp5
11 files changed, 207 insertions, 10 deletions
diff --git a/tests/test/tandorandnot1.pp b/tests/test/tandorandnot1.pp
new file mode 100644
index 0000000000..aff04507ea
--- /dev/null
+++ b/tests/test/tandorandnot1.pp
@@ -0,0 +1,34 @@
+{ test (a and b) or (c and not(b)) into c xor ((c xor a) and b) optimization with random values }
+var
+ i,a,b,c,_a,_b,_c : word;
+begin
+ for i:=1 to 1000 do
+ begin
+ a:=random(65536);
+ _a:=a;
+ b:=random(65536);
+ _b:=b;
+ c:=random(65536);
+ _c:=c;
+ if (a and b) or (c and not(b))<>_c xor ((_c xor _a) and _b) then
+ begin
+ writeln('Error: ','a=',a,'b=',b,'c=',c);
+ halt(1);
+ end;
+ if (a and b) or (not(b) and c)<>_c xor ((_c xor _a) and _b) then
+ begin
+ writeln('Error: ','a=',a,'b=',b,'c=',c);
+ halt(1);
+ end;
+ if (not(b) and c) or (a and b)<>_c xor ((_c xor _a) and _b) then
+ begin
+ writeln('Error: ','a=',a,'b=',b,'c=',c);
+ halt(1);
+ end;
+ if (not(b) and c) or (b and a)<>_c xor ((_c xor _a) and _b) then
+ begin
+ writeln('Error: ','a=',a,'b=',b,'c=',c);
+ halt(1);
+ end;
+ end;
+end.
diff --git a/tests/test/tmt1.pp b/tests/test/tmt1.pp
index b2992963ed..c4a50d5217 100644
--- a/tests/test/tmt1.pp
+++ b/tests/test/tmt1.pp
@@ -11,9 +11,9 @@ uses
;
const
-{$ifdef cpuarm}
+{$if defined(cpuarm) or defined(cpuavr) or defined(cpui8086) or defined(cpum68k) or defined(cpumips) or defined(cpuz80)}
{$define slowcpu}
-{$endif cpuarm}
+{$endif}
{$ifdef slowcpu}
threadcount = 40;
diff --git a/tests/test/units/strutils/tboyer.pp b/tests/test/units/strutils/tboyer.pp
new file mode 100644
index 0000000000..7eb6fda835
--- /dev/null
+++ b/tests/test/units/strutils/tboyer.pp
@@ -0,0 +1,79 @@
+{$mode objfpc}
+
+uses
+ StrUtils;
+const
+ result1 : array of SizeInt = (1, 4, 7, 10, 13, 16);
+var
+ a : array of SizeInt;
+ i : LongInt;
+begin
+ if FindMatchesBoyerMooreCaseSensitive('abcabcabcabcabcabcab','abcab',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(2);
+ if a[0]<>result1[0] then
+ halt(3);
+ end
+ else
+ halt(1);
+
+ if FindMatchesBoyerMooreCaseSensitive('abcabcabcabcabcabcab','abcab',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(12);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(13);
+ end
+ else
+ halt(11);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcabcabcabcab','abcab',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(22);
+ if a[0]<>result1[0] then
+ halt(23);
+ end
+ else
+ halt(21);
+
+{
+ apparently not working yet:
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcabcabcabcab','abcab',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(32);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(33);
+ end
+ else
+ halt(31);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabcabcAbcabcAbcab','abcaB',a,false) then
+ begin
+ if Length(a)<>1 then
+ halt(42);
+ if a[0]<>result1[0] then
+ halt(43);
+ end
+ else
+ halt(41);
+
+ if FindMatchesBoyerMooreCaseInSensitive('abcabCabcAbcabcABcab','abcaB',a,true) then
+ begin
+ if Length(a)<>Length(result1) then
+ halt(52);
+ for i:=Low(a) to High(a) do
+ if a[i]<>result1[i] then
+ halt(53);
+ end
+ else
+ halt(51);
+}
+
+ writeln('ok');
+end.
diff --git a/tests/utils/dotest.pp b/tests/utils/dotest.pp
index 9aa88073f0..fd248b97d0 100644
--- a/tests/utils/dotest.pp
+++ b/tests/utils/dotest.pp
@@ -839,7 +839,7 @@ end;
function RunCompiler(const ExtraPara: string):boolean;
var
args,LocalExtraArgs,
- wpoargs : string;
+ wpoargs,wposuffix : string;
passnr,
passes : longint;
execres : boolean;
@@ -880,6 +880,7 @@ begin
if Config.NeedOptions<>'' then
AppendOptions(Config.NeedOptions,args);
wpoargs:='';
+ wposuffix:='';
if (Config.WpoPasses=0) or
(Config.WpoParas='') then
passes:=1
@@ -891,6 +892,7 @@ begin
begin
if (passes>1) then
begin
+ wposuffix:='_'+tostr(passnr);
wpoargs:=' -OW'+config.wpoparas+' -FW'+TestOutputFileName('',PPFile[current],'wp'+tostr(passnr));
if (passnr>1) then
wpoargs:=wpoargs+' -Ow'+config.wpoparas+' -Fw'+TestOutputFileName('',PPFile[current],'wp'+tostr(passnr-1));
@@ -899,12 +901,12 @@ begin
{ also get the output from as and ld that writes to stderr sometimes }
StartTicks:=GetMicroSTicks;
{$ifndef macos}
- execres:=ExecuteRedir(CompilerBin,args+wpoargs,'',CompilerLogFile,'stdout');
+ execres:=ExecuteRedir(CompilerBin,args+wpoargs,'',CompilerLogFile+wposuffix,'stdout');
{$else macos}
{Due to that Toolserver is not reentrant, we have to asm and link via script.}
- execres:=ExecuteRedir(CompilerBin,'-s '+args+wpoargs,'',CompilerLogFile,'stdout');
+ execres:=ExecuteRedir(CompilerBin,'-s '+args+wpoargs,'',CompilerLogFile+wposuffix,'stdout');
if execres then
- execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile,'stdout');
+ execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile+wpo_suffix,'stdout');
{$endif macos}
EndTicks:=GetMicroSTicks;
Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
@@ -913,6 +915,8 @@ begin
Verbose(V_Normal,'Compilation took '+ToStr(EndTicks-StartTicks)+' us');
end;
+ if passes > 1 then
+ CopyFile(CompilerLogFile+wposuffix,CompilerLogFile,true);
{ Error during execution? }
if (not execres) and (ExecuteResult=0) then
begin
diff --git a/tests/webtbf/tw38504.pp b/tests/webtbf/tw38504.pp
new file mode 100644
index 0000000000..6eb43cac70
--- /dev/null
+++ b/tests/webtbf/tw38504.pp
@@ -0,0 +1,11 @@
+{ %fail }
+Var
+ MyVar : char;
+
+Procedure MyProc;
+Begin
+ MyVar := ''; (* <-- two single-quotes *)
+End;
+
+Begin
+End.
diff --git a/tests/webtbf/tw38504b.pp b/tests/webtbf/tw38504b.pp
new file mode 100644
index 0000000000..211f763d03
--- /dev/null
+++ b/tests/webtbf/tw38504b.pp
@@ -0,0 +1,11 @@
+{ %fail }
+Var
+ MyVar : char;
+
+Procedure MyProc;
+Begin
+ MyVar := char('');
+End;
+
+Begin
+End.
diff --git a/tests/webtbs/tw28713.pp b/tests/webtbs/tw28713.pp
index e0879f1cc3..d27b8bb138 100644
--- a/tests/webtbs/tw28713.pp
+++ b/tests/webtbs/tw28713.pp
@@ -6,7 +6,14 @@ type
TWordArray = array [0..1023]of Word;
WordRec = packed record
+{$ifdef FPC}
+{$ifdef FPC_LITTLE_ENDIAN}
LoByte,HiByte:Byte
+{$endif}
+{$ifdef FPC_BIG_ENDIAN}
+ HiByte,LoByte:Byte
+{$endif}
+{$endif}
end;
var
diff --git a/tests/webtbs/tw36250.pp b/tests/webtbs/tw36250.pp
new file mode 100644
index 0000000000..569294da6f
--- /dev/null
+++ b/tests/webtbs/tw36250.pp
@@ -0,0 +1,15 @@
+{ %norun }
+{ %target=darwin,ios,iphonesim}
+{ %opt=-gw3 }
+
+{$mode objfpc}{$h+}
+{$ModeSwitch objectivec2}
+
+function NSStringToString(ns: NSString): String;
+begin
+ Result := '';
+end;
+
+begin
+ WriteLn(NSStringToString(nil));
+end.
diff --git a/tests/webtbs/tw38497.pp b/tests/webtbs/tw38497.pp
new file mode 100644
index 0000000000..4c8c5ebcb9
--- /dev/null
+++ b/tests/webtbs/tw38497.pp
@@ -0,0 +1,24 @@
+program project1;
+
+{$mode delphi}
+
+type
+ TAlphabet = (A, B, C);
+ TAlphabets = set of TAlphabet;
+
+ procedure Test<TEnum, TSet>(E: TEnum; S: TSet);
+ var
+ I: TEnum;
+ B: Boolean;
+ begin
+ B := [E] <= S;
+ if E in S then
+ WriteLn(E);
+ for I := Low(TEnum) to High(TEnum) do
+ if I in S then
+ WriteLn(I);
+ end;
+
+begin
+ Test<TAlphabet, TAlphabets>(A, [A, B]);
+end.
diff --git a/tests/webtbs/tw38527.pp b/tests/webtbs/tw38527.pp
new file mode 100644
index 0000000000..4f50d92bc8
--- /dev/null
+++ b/tests/webtbs/tw38527.pp
@@ -0,0 +1,15 @@
+{%OPT=-O2}
+
+{$mode objfpc}
+
+function F(n: SizeUint): SizeUint;
+begin
+ result := 4 * n + 4 * n;
+end;
+
+begin
+ writeln('Reference F(5): ', 4 * 5 + 4 * 5);
+ writeln(' Actual F(5): ', F(5));
+ if (F(5) <> 40) then
+ halt(1);
+end.
diff --git a/tests/webtbs/tw8177.pp b/tests/webtbs/tw8177.pp
index 4b410fabf4..c2e7e05eec 100644
--- a/tests/webtbs/tw8177.pp
+++ b/tests/webtbs/tw8177.pp
@@ -6,10 +6,7 @@ program ValidateStrToInt;
{$mode delphi}
{$ENDIF}
-{$ifdef cpuarm}
- {$define slowcpu}
-{$endif}
-{$ifdef cpumips}
+{$if defined(cpuarm) or defined(cpuavr) or defined(cpui8086) or defined(cpum68k) or defined(cpumips) or defined(cpuz80)}
{$define slowcpu}
{$endif}
{$ifdef android}