You've sent this to the Gradle mailing list. Did you mean the Groovy mailing 
list?

On 16/09/2012, at 5:30 AM, Alan Krueger wrote:

> On the Groovy "Using methodMissing and propertyMissing" page, it has this 
> sample code:
> class Foo
> 
>         {
>  def
>  storage = [:]
>       
> def
>  propertyMissing(String name, value)
>         { storage[name] = value } 
> def
> 
>         propertyMissing(String name) { storage[name] }
>         }
>       
> def f = new
>  Foo()
>         f.foo = 
> "bar"
> 
>         assertEquals 
> "bar", f.foo
> Plugging this into foo.groovy and running that as a Groovy script (changing 
> the assertEquals to a println), it works as expected.  Because I've been 
> having trouble getting propertyMissing to work properly for me, I tried to 
> turn the above into a JUnit test:
> import static
>           org.junit.Assert.assertEquals
> 
> 
>           
> 
> 
>           import org.junit.Test
> 
> 
>           
> 
> 
>           class PropertyMissingTest {
> 
> 
>           class Foo {
> 
> 
>           def storage = [:]
> 
> 
>           def propertyMissing(String name, value) { storage[name] =
>           value }
> 
> 
>           def propertyMissing(String name) { storage[name] }
> 
> 
>           }
> 
> 
>           
> 
> 
>           @Test
> 
> 
>           void test() {
> 
> 
>           def f = new Foo()
> 
> 
>           f.foo = "bar"
> 
> 
>           assertEquals "bar", f.foo
> 
> 
>           }
> 
> 
>           }
> 
> Unfortunately, when I run that I get this:
> java.lang.VerifyError: (class: PropertyMissingTest$Foo, method: 
> propertyMissing signature: 
> (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;) Wrong return type 
> in function
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:186)
>     at PropertyMissingTest.class$(PropertyMissingTest.groovy)
>     at 
> PropertyMissingTest.$get$$class$PropertyMissingTest$Foo(PropertyMissingTest.groovy)
>     at PropertyMissingTest.test(PropertyMissingTest.groovy:14)
> [...]
> I've gone over this multiple times and am a bit stumped.  Any suggestions on 
> why this isn't working?
> 

-- 
Luke Daley
Principal Engineer, Gradleware 
http://gradleware.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to