Closed HamletDRC closed 14 years ago
what groovy version do you use - it works in my test suite with 1.7.2...
okay, i guess you do not work with the most current master source - ClassInvariantGenerator line 94 does not contain any executable code :-)
I did a git pull && mvn clean install at 8 AM this morning GMT
sorry but there has been some inconsistency between my local and the remote git repository - please pull the source again. the person test case has been added to the test suite.
I do this:
git pull && mvn clean install
then launch GroovyConsole, copy the script in, load the JAR, click run, and get the same error.
hm, you mean with the exact same stacktrace above?
I am wondering, because
ClassInvariantGenerator.generateDefaultInvariantAssertionStatement (ClassInvariantGenerator.java:94)
is an empty line in the current master source.
the new stack trace has different line numbers Jun 11, 2010 12:19:07 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize WARNING: Sanitizing stacktrace: java.lang.ClassCastException: org.codehaus.groovy.ast.stmt.ExpressionStatement cannot be cast to org.codehaus.groovy.ast.stmt.BlockStatement at org.gcontracts.generation.ClassInvariantGenerator.generateInvariantAssertionStatement(ClassInvariantGenerator.java:73) at org.gcontracts.generation.ClassInvariantGenerator.generateDefaultInvariantAssertionStatement(ClassInvariantGenerator.java:93) at org.gcontracts.ast.visitor.ContractsVisitor.visitClass(ContractsVisitor.java:81) at org.gcontracts.ast.ContractValidationASTTransformation.visit(ContractValidationASTTransformation.java:62)
attaching the file i am running in groovyConsole
issue is fixed in current master.
it works for me now thanks
This script worked just fine in 1.0.1:
package gcontracts
import org.gcontracts.annotations.Invariant import org.gcontracts.annotations.Requires import org.gcontracts.annotations.Ensures
@Invariant({ firstName != null && lastName != null }) class Person { String firstName String lastName
@Requires ({ delimiter in ['.', ',', ' '] }) @Ensures({ result == (firstName + delimiter + lastName) }) def String getName(String delimiter) { return delimiter } }
println new Person()
It is now broken. I get this exception with the latest source build:
Caused by: java.lang.ClassCastException: org.codehaus.groovy.ast.stmt.ExpressionStatement cannot be cast to org.codehaus.groovy.ast.stmt.BlockStatement at org.gcontracts.generation.ClassInvariantGenerator.generateInvariantAssertionStatement(ClassInvariantGenerator.java:73) at org.gcontracts.generation.ClassInvariantGenerator.generateDefaultInvariantAssertionStatement(ClassInvariantGenerator.java:94)