Instantly share code, notes, and snippets.

Embed
What would you like to do?
Did i just find a bug in @canonical or am i thick ? #groovy
#!/usr/bin/env groovy
import groovy.transform.Canonical
def weird = new CanonicalIsWeird(a: 'first letter', b: 'second letter')
println "a: ${weird.a}"
println "b: ${weird.b}"
assert weird.a == 'first letter'
assert weird.b == 'second letter'
@Canonical
class CanonicalIsWeird {
def a, b
}
@breun

This comment has been minimized.

Show comment
Hide comment
@breun

breun Jan 5, 2012

I'm not sure, but it looks weird to me.

$ groovy -v
Groovy Version: 1.8.5 JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X
$ ./test.groovy 
a: [a:first letter, b:second letter]
b: 
Caught: Assertion failed: 

assert weird.a == 'first letter'
       |     | |
       |     | false
       |     [a:first letter, b:second letter]
       CanonicalIsWeird([a:first letter, b:second letter], )

Assertion failed: 

assert weird.a == 'first letter'
       |     | |
       |     | false
       |     [a:first letter, b:second letter]
       CanonicalIsWeird([a:first letter, b:second letter], )

        at test.run(test.groovy:9)```

breun commented Jan 5, 2012

I'm not sure, but it looks weird to me.

$ groovy -v
Groovy Version: 1.8.5 JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X
$ ./test.groovy 
a: [a:first letter, b:second letter]
b: 
Caught: Assertion failed: 

assert weird.a == 'first letter'
       |     | |
       |     | false
       |     [a:first letter, b:second letter]
       CanonicalIsWeird([a:first letter, b:second letter], )

Assertion failed: 

assert weird.a == 'first letter'
       |     | |
       |     | false
       |     [a:first letter, b:second letter]
       CanonicalIsWeird([a:first letter, b:second letter], )

        at test.run(test.groovy:9)```
@gjoseph

This comment has been minimized.

Show comment
Hide comment
@gjoseph

gjoseph Jan 5, 2012

Indeed. I was expecting both assertions to pass.

Owner

gjoseph commented Jan 5, 2012

Indeed. I was expecting both assertions to pass.

@paulk-asert

This comment has been minimized.

Show comment
Hide comment
@paulk-asert

paulk-asert Jan 6, 2012

Can you raise a Jira please. The workaround is to give types to your properties, e.g. String in this case - for at least the first property.

paulk-asert commented Jan 6, 2012

Can you raise a Jira please. The workaround is to give types to your properties, e.g. String in this case - for at least the first property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment