Browse Source

bug0222-226

pierre 26 years ago
parent
commit
3c4f80fc69
5 changed files with 82 additions and 0 deletions
  1. 11 0
      tests/tbs0222.pp
  2. 20 0
      tests/tbs0223.pp
  3. 12 0
      tests/tbs0224.pp
  4. 30 0
      tests/tbs0225.pp
  5. 9 0
      tests/tbs0226.pp

+ 11 - 0
tests/tbs0222.pp

@@ -0,0 +1,11 @@
+
+type TStruct = record 
+ 		 x,y: Integer;
+               end; 
+
+var i: TStruct;    
+
+begin
+  for i.x:=1 to 10 do
+    writeln(i.x);
+end.

+ 20 - 0
tests/tbs0223.pp

@@ -0,0 +1,20 @@
+
+uses 
+   erroru;
+
+var a:string;
+
+begin
+  writeln('B:'='B:');            { debbuger evaluates this to FALSE }
+  if 'B:'='B:' then
+    writeln('OK')
+  else
+    error;
+  a:='A:';
+  inc(a[1]);
+  writeln(a='B:');               { TRUE }
+  if a='B:' then
+    writeln('OK')
+  else
+    error;
+end.

+ 12 - 0
tests/tbs0224.pp

@@ -0,0 +1,12 @@
+
+var f:text;
+    i:integer;
+begin
+  assign(f,'bug0224.txt');
+  reset(f);
+{$I-}
+  readln(f,i);              { you can't avoid run-time error generation }
+{$I+}
+  if IOResult<>0 then writeln('error...')
+                 else close(f);
+end.

+ 30 - 0
tests/tbs0225.pp

@@ -0,0 +1,30 @@
+ program bug0255;
+
+{$mode objfpc}
+
+{$R+}
+
+  function erwwert(const feld: array of LongInt):extended;
+   var i: LongInt;
+   begin
+    Result:=0;
+    for i:=low(feld) to high(feld)
+        do begin
+            writeln(i);  // gives "0"
+            Result:=Result+feld[i];
+           end;          //^^^^^^^ there occurs the segfault (216)
+                         //        on the first loop
+    Result:=Result/(high(feld)-low(feld)+1);
+   end;
+
+ var werte: array[0..299] of LongInt;
+     i: LongInt;
+
+ begin
+  //init the array
+  for i:=0 to 299
+      do werte[i]:=Random(5)-2;
+
+  //and do something with it
+  writeln(erwwert(werte):6:5);
+ end.

+ 9 - 0
tests/tbs0226.pp

@@ -0,0 +1,9 @@
+{$ifdef fpc}{$asmmode intel}{$endif}
+var
+  test : longint;
+begin
+  exit; { don't run this code below !! }
+  asm
+    dd    test
+  end;
+end.