I have a Map implementation that implements Comparable. I am using groovy/spock to test it.
In groovy, a == b checks first for a compareTo() method and uses a.compareTo(b) == 0 if a compareTo() method exists. But I want groovy to do it's regular Map comparison (keys and values match), even if the class of the two objects are different (eg comparing MyComparableMap with a LinkedHashMap).
Is there a (simple) way to force the regular Map comparison instead of the Comparable way, without writing my own code to do this?
I've tried equals() but that doesn't work. I can't compare entrySet(), because not all test cases involve Maps.
Aucun commentaire:
Enregistrer un commentaire