mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-28 09:39:13 +02:00
tests: add SafeCallException test
git-svn-id: trunk@14941 -
This commit is contained in:
parent
cf0a1b1af9
commit
f607b7bdd5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -9261,6 +9261,7 @@ tests/test/trtti2.pp svneol=native#text/plain
|
||||
tests/test/trtti3.pp svneol=native#text/plain
|
||||
tests/test/trtti4.pp svneol=native#text/plain
|
||||
tests/test/trtti5.pp svneol=native#text/plain
|
||||
tests/test/tsafecall1.pp svneol=native#text/plain
|
||||
tests/test/tsealed1.pp svneol=native#text/pascal
|
||||
tests/test/tsealed2.pp svneol=native#text/pascal
|
||||
tests/test/tsealed3.pp svneol=native#text/pascal
|
||||
|
33
tests/test/tsafecall1.pp
Normal file
33
tests/test/tsafecall1.pp
Normal file
@ -0,0 +1,33 @@
|
||||
{ %TARGET=win32,win64,wince}
|
||||
{$ifdef fpc}
|
||||
{$mode objfpc}
|
||||
{$endif}
|
||||
uses
|
||||
SysUtils;
|
||||
type
|
||||
TTest = class
|
||||
public
|
||||
procedure SomeError; safecall;
|
||||
function SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult; override;
|
||||
end;
|
||||
|
||||
var
|
||||
Handled: Boolean;
|
||||
|
||||
procedure TTest.SomeError; safecall;
|
||||
begin
|
||||
raise Exception.Create('SomeException');
|
||||
end;
|
||||
|
||||
function TTest.SafeCallException(ExceptObject: TObject; ExceptAddr: Pointer): HResult;
|
||||
begin
|
||||
Handled := True;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
begin
|
||||
Handled := False;
|
||||
TTest.Create.SomeError;
|
||||
if not Handled then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user