+ some more bug tests

This commit is contained in:
pierre 2000-03-14 16:29:13 +00:00
parent 34795ccd60
commit 707b1003a8
5 changed files with 102 additions and 3 deletions

39
tests/webtbs/tbug825.pp Normal file
View File

@ -0,0 +1,39 @@
{$mode tp}
{ args for destructors
are allowed in TP mode for compatibility only PM }
program test_destructor_with_args;
var
z : longint;
type
tt = object
constructor dummy;
destructor done(x : longint);virtual;
end;
constructor tt.dummy;
begin
end;
destructor tt.done;
begin
Writeln('x in tt.done is ',x);
z:=x;
end;
var
pt : ^tt;
begin
Writeln('ln(5)=',ln(5));
new(pt,dummy);
pt^.done(4);
if z<>4 then
Halt(1);
pt^.dummy;
dispose(pt,done(5));
if z<>5 then
Halt(1);
end.

View File

@ -3,8 +3,7 @@
PROCEDURE a;
VAR v,v2,v3:integer;
PROCEDURE b;
BEGIN
PROCEDURE b;assembler;
ASM
MOV AX,v
mov v2,AX
@ -13,7 +12,6 @@ VAR v,v2,v3:integer;
MOV AX,[EBP+OFFSET v]
MOV v3,AX
END;
END;
BEGIN
v:=5;

17
tests/webtbs/tbug866.pp Normal file
View File

@ -0,0 +1,17 @@
{$mode objfpc}
Type
ts = set of (tse);
ts2 = set of (t1,t2);
enum3 = (tm1:=-1,t0,tp1);
ts3 = set of t0 .. tp1;
var
f:ts;
f2 : ts2;
f3 : ts3;
begin
f2:=f2+[t2];
f2:=f2+[t1];
f:=f+[tse]; // compiler says that set elements are not compatible
{ f3:=[tm1];}
end.

24
tests/webtbs/tbug869.pp Normal file
View File

@ -0,0 +1,24 @@
program prueba;
uses crt;
var
resultado,exponente:integer;
begin
exponente := 3;
resultado := -1 ** exponente;
writeln (resultado);
if resultado<>-1 then
Halt(1);
exponente := 4;
resultado := -(1 ** exponente);
writeln (resultado);
if resultado<>-1 then
Halt(1);
resultado := (-1) ** exponente;
writeln (resultado);
if resultado<>1 then
Halt(1);
resultado := -1 ** exponente;
writeln (resultado);
if resultado<>-1 then
Halt(1);
end.

21
tests/webtbs/tbug870.pp Normal file
View File

@ -0,0 +1,21 @@
{$mode objfpc}
uses sysUtils;
type
t = object
f:integer;
function m: AnsiString;
end;
function t.m: AnsiString;
begin
result:=IntToStr(f);
end;
var ti:t;
begin
ti.f:=1; // no vmt for t - constructor call is not needed
writeln(format('%s', [ti.m])); // this works
writeln(format('%s, %s', [ti.m, ti.m])); // this does not - the same story with classes
end.