Re: [Vala] GLib.assert_no_error not working?



    > On Friday, 9 March 2018, 00:17:30 GMT, Michael Gratton <mike vee net> wrote:  >> On Thu, Mar 8, 2018 at 
9:26 PM, Al Thomas <astavale yahoo co uk> wrote:
The assertion is in a catch block so err will be set. Whereas 
assert_no_error
is used to check err is unset (i.e. null). The line about 'produce a 
message that includes
the error message and code' seems like a copy/paste error in the 
documentation.

That doesn't seem right at all. What's the point of the argument then?
Of course! I hope I understand now. assert_no_error is used to check the error is unset. The assertion is 
from GLib and used with C.So in C you have GError as an out argument and if the argument is nullthen 
assert_no_error passes. That is the point of the argument.

In Vala, however, the GError is hidden. It is only exposed inside the catch block and so will always be set. 
So I think I understand now. You know the error willalways be set so it will always fail and then print the 
values of the GError.I have difficulty taking in the idea of asserting there is no error in a catch 
block.Maybe assert_not_reached would be clearer and just print the err.message before.Although it is a little 
more code.

Thinking it through again, it looks like assert_no_error is broken in GLib.I think assert_false is as well. 
Have you ever tried assert_false( false )?That should pass, but fails for me.
Regards,
Al
  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]