BigDecimals carry both a numerical value and a precision (scale).
In Groovy, when BigDecimals are compared, only the numerical value is taken into account, but isCase() uses both value and scale.
This should be consistent.
assert 0.5 == 0.50000 // works
switch(0.5) {
case 0.50000: println "match" // doesn't match
}
public static boolean isCase(Number caseValue, Number switchValue) {
return NumberMath.compareTo(caseValue, switchValue)==0;
}
The attached patch contains this method and adds some tests to SwitchWithDifferentTypesTest.groovy.