|
Groovy example source code file (CompareEqualsTest.groovy)
The Groovy CompareEqualsTest.groovy source code
package groovy
class CompareEqualsTest extends GroovyTestCase {
void testEqualsOperatorIsMultimethodAware() {
assert new Xyz() == new Xyz()
assertEquals new Xyz(), new Xyz()
shouldFail {
assert new Xyz() == 239
}
assert new Xyz () == "GROOVY.XYZ"
}
}
class Xyz {
boolean equals(Xyz other) {
println "${other.class} TRUE"
true
}
boolean equals(Object other) {
println "${other.class} FALSE"
null
}
boolean equals(String str) {
str.equalsIgnoreCase this.class.getName()
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy CompareEqualsTest.groovy source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.