andresteingress / gcontracts

GContracts: Programming by Contract for Groovy
http://gcontracts.org
114 stars 11 forks source link

use Groovy power asserts as an alternative to AssertionStatement #7

Closed andresteingress closed 14 years ago

andresteingress commented 14 years ago

it would be great if there would be a way to join Groovy's power asserts with gcontracts error messages - the programmer could get immediate results where the boolean expression failed.

andresteingress commented 14 years ago

currently the generated assertion statements use custom messages. this avoids use of power assertions.

andresteingress commented 14 years ago

alternative approach is to use assert statements without assertion messages catch the PowerAssertionError and rethrow the assertion error with the message from the PAE

andresteingress commented 14 years ago

played a bit with rethrowing PAEs in groovyConsole. it is not that easy e.g. to add a prefix like 'invariant violated: ' since a power assert message has line pointers pointing at code positions. modifying a PAE message would than mean to recompute all line pointers and therefore introducing a dependency on the power assert message layout.

pniederw commented 14 years ago

Add two newlines between your message and the power assert output. Looks better anyway. You could also just move the whole power assert output to the right (i.e. add spaces add the beginning of each line), but I don't think it's necessary.

andresteingress commented 14 years ago

fixed in master