Closed HamletDRC closed 14 years ago
jup, you are right, better error messages are on top of my todo list.
i wanted to talk to peter in our next ejug meeting on his opinion about using power assertions in gcontracts. i really like the idea of getting a detailed explanation of what went wrong in an invariant/pre/postcondition.
also, if you want to capture the code take a look at Groovy-core AstBuilder.buildFromCode. It does that as well. Power asserts is the way to go though.
okay, i'll have a look at it
check out the convertClosureToSource method in: http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/org/codehaus/groovy/ast/builder/AstBuilderTransformation.groovy
fixed in current master.
the message text should know look like:
[invariant] Invariant in class
preferred way is still the integration of power asserts, i am going to have a look at that topic in the next major version.
nice response time :)
The Class invariant produces error message that could be improved.
Here is one such exception: java.lang.AssertionError: [invariant] Invariant in class violated. Expression: this.$invariant$Ariane5.call()
at gcontracts.Ariane5.accelerate(Ariane5.groovy:11)
at gcontracts.Ariane5Test.test overflow(Ariane5Test.groovy:26)
It is possible in an AST Transformation to capture the source that produced a statement. You could capture the @Invariant source and and print it out as part of the failure message.