Browse Source

Check that a normal real division does not generate an exception

Pierre Muller 8 months ago
parent
commit
564d50ce8e
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/test/texception4.pp

+ 20 - 0
tests/test/texception4.pp

@@ -20,6 +20,15 @@ procedure test_exception(const s : string);
       end;
   end;
 
+procedure test_no_exception(const s : string);
+  begin
+    if exception_called then
+      begin
+        Writeln('Unexpected exception called : ',s);
+        Program_has_errors := true;
+      end;
+  end;
+
 var
    i,j : longint;
    e : extended;
@@ -62,6 +71,17 @@ begin
    test_exception('First division by zero for reals');
    try
    exception_called:=false;
+   e:=i/(j+3.5);
+   except
+     on e : exception do
+       begin
+         Writeln('Wrong exception called ',e.message);
+         exception_called:=true;
+       end;
+   end;
+   test_no_exception('Allowed division by zero for reals after first division by zero for reals');
+   try
+   exception_called:=false;
    e:=i/j;
    except
      on e : exception do