[fpc-pascal] Re: FPCUnit test + raise E;

2013-09-14 Thread Marcos Douglas
On Sat, Sep 14, 2013 at 10:21 PM, Marcos Douglas  wrote:
> Hi,
>
> 1) I have a code like that:
>
> procedure TghSQLConnector.Connect;
> begin
>   try
> FLib.Connect;
>   except
> on E: Exception do
>   DoOnException(E);
>   end;
> end;
>
>  https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565
>
>
> 2) DoOnException was implemented so:
>
> procedure TghSQLHandler.DoOnException(E: Exception);
> begin
>   if Assigned(FOnException) then
> FOnException(Self, E)
>   else
> raise E;
> end;
>
> https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443
>
>
> So, as you see, if occurs a Exception the code checks if the event
> (OnException) was setted. If yes, call user implementation; if no,
> call raise E;
> It works... but not when I uses in FPCUnit tests.
>
> See a simple test (this works):
>
> procedure TghSQLConnectorTest.TestOnException;
> begin
>   // catch
>   FConn.OnException := @DoOnException;
>   FConn.Script.Text := 'foo';
>   FConn.Execute;
> end;
>
> https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246
>
>
> The code DoOnException is:
>
> procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception);
> begin
>   AssertTrue(Assigned(E));
> end;
>
> https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141
>
> So, if I change the test like bellow... BUM! SIGSEGV!!
>
> procedure TghSQLConnectorTest.TestOnException;
> begin
>   // removed >>> FConn.OnException := @DoOnException;
>   FConn.Script.Text := 'foo';
>   FConn.Execute;
> end;
>
>
> The ERROR is:
> [Content]
> Project test raised exception class 'External: SIGSEGV'.
>
>  At address 40B758
>
>
> Can you explain this?

I forgot. I'm using Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64
I want to know if there is a problem in FPCUnit to catch some
exceptions. That's all.

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Parser bug or what?

2013-09-14 Thread Daniel Gaspary
Can anybody tell me whether I stepped on a bug  or I am just
forgetting some Set / Enum property?

I made a Set to iterate with For..in, but I accidentally used a Dot
instead of a Comma between the elements.

The result was that the For "sees" only the item(s) after the Dot as the Example

What's Happening in the example ??

program Project1;
type
TMyEnum = (me1, me2, me3);
TMyEnumSet = set of TMyEnum;
var
   e: TMyEnum;
begin
 for e in [me1 . me2] do  //It's a dot, not a comma
 WriteLn(e);
end.

It works with other combinations, like:

[me1 . me2. me3.]  // DOT DOT DOT
[me1 , me2. me3.]  // COMMA DOT DOT

My FPC version: 2.7.1 [2013/03/26] for x86_64
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] FPCUnit test + raise E;

2013-09-14 Thread Marcos Douglas
Hi,

1) I have a code like that:

procedure TghSQLConnector.Connect;
begin
  try
FLib.Connect;
  except
on E: Exception do
  DoOnException(E);
  end;
end;

 https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565


2) DoOnException was implemented so:

procedure TghSQLHandler.DoOnException(E: Exception);
begin
  if Assigned(FOnException) then
FOnException(Self, E)
  else
raise E;
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443


So, as you see, if occurs a Exception the code checks if the event
(OnException) was setted. If yes, call user implementation; if no,
call raise E;
It works... but not when I uses in FPCUnit tests.

See a simple test (this works):

procedure TghSQLConnectorTest.TestOnException;
begin
  // catch
  FConn.OnException := @DoOnException;
  FConn.Script.Text := 'foo';
  FConn.Execute;
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246


The code DoOnException is:

procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception);
begin
  AssertTrue(Assigned(E));
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141

So, if I change the test like bellow... BUM! SIGSEGV!!

procedure TghSQLConnectorTest.TestOnException;
begin
  // removed >>> FConn.OnException := @DoOnException;
  FConn.Script.Text := 'foo';
  FConn.Execute;
end;


The ERROR is:
[Content]
Project test raised exception class 'External: SIGSEGV'.

 At address 40B758


Can you explain this?

Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal