* runtime tests fixed

This commit is contained in:
peter 2002-11-26 23:00:58 +00:00
parent 5c9b8361a4
commit af371f5a97
2 changed files with 33 additions and 8 deletions

View File

@ -3,7 +3,7 @@
{ Source provided for Free Pascal Bug Report 2159 }
{ Submitted by "Yakov Sudeikin" on 2002-10-03 }
{ e-mail: yashka@exebook.com }
{$mode objfpc}
{$ifdef fpc}{$mode objfpc}{$endif}
var
a,b,c: array of string;
@ -13,5 +13,20 @@ begin
a[1] := 'qwe';
b := copy(a);
c := copy(a, 1, 1);
if b[0]<>'asd' then
begin
writeln('Error 1');
halt(1);
end;
if b[1]<>'qwe' then
begin
writeln('Error 2');
halt(1);
end;
if c[0]<>'qwe' then
begin
writeln('Error 3');
halt(1);
end;
end.

View File

@ -31,7 +31,7 @@ list_of_string=
stack_of_string=
packed object (list_of_string)
procedure pop(var s:string);
procedure push(var s:string);
procedure push(const s:string);
end;
procedure writestring(var f:file;s:string);
@ -136,7 +136,7 @@ var
begin
l:=len;
blockwrite(f,l,sizeof(longint));
if l>0 then p:=first;
p:=first;
for i:=1 to l do
begin
p^.save(f);
@ -171,19 +171,29 @@ begin
end;
end;
procedure stack_of_string.push(var s:string);
procedure stack_of_string.push(const s:string);
begin
insert(anchor,s);
end;
var
gs:stack_of_string;
opaddr : pointer;
opaddr : ^string;
begin
opaddr:=@((gs.first)^.data);
{perfectly compiles}
gs.init(nil);
gs.push('test');
{perfectly compiles}
opaddr:=@((gs.first)^.data);
writeln(opaddr^);
if (opaddr^<>'test') then
halt(1);
opaddr:=@(gs.first^.data);
{reports error ") expected ^ but found"}
opaddr:=@(gs.first^.data);
writeln(opaddr^);
if (opaddr^<>'test') then
halt(1);
end.