{: test that external files are terminated after a fatal error }

{$d+}
program x001( output, xf );

var
   k : real;
   xf : text;

function side : real;
begin
   side := k;
   k := k+1;
end; { side }

procedure p;
begin
   writeln( 'sqrt(-1) is ', sqrt(-1):9 ); {error}
end; { p }

begin {x001}

   rewrite(xf);
   write( xf, 'this line should get terminated after error' );

   p;
   writeln( 'fails: sqrt < 0 error is not detected' );
   writeln(xf);
   writeln( xf, 'error is not detected, test invalid' );
end. { x001 }

