Browse Source

* runtime tests fixed

peter 23 years ago
parent
commit
af371f5a97
2 changed files with 32 additions and 7 deletions
  1. 16 1
      tests/webtbs/tw2159.pp
  2. 16 6
      tests/webtbs/tw2178.pp

+ 16 - 1
tests/webtbs/tw2159.pp

@@ -3,7 +3,7 @@
 { Source provided for Free Pascal Bug Report 2159 }
 { Submitted by "Yakov Sudeikin" on  2002-10-03 }
 { e-mail: [email protected] }
-{$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.
 

+ 16 - 6
tests/webtbs/tw2178.pp

@@ -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);
+  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.