Skip to content

Commit

Permalink
NAME_ASCENDING comparator is now more clear, DEFAULT delegates to
Browse files Browse the repository at this point in the history
NAME_ASCENDING in case the hash codes are equal. no more private compare
method
  • Loading branch information
ibeauregard committed May 31, 2012
1 parent d76010f commit ec7fd69
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/junit/internal/MethodSorter.java
Expand Up @@ -17,7 +17,7 @@ public int compare(Method m1, Method m2) {
if (i1 != i2) {
return i1 < i2 ? -1 : 1;
}
return MethodSorter.compare(m1.toString(), m2.toString());
return NAME_ASCENDING.compare(m1, m2);
}
};

Expand All @@ -26,13 +26,13 @@ public int compare(Method m1, Method m2) {
*/
public static Comparator<Method> NAME_ASCENDING= new Comparator<Method>() {
public int compare(Method m1, Method m2) {
return MethodSorter.compare(m1.getName() + m1.toString(), m2.getName() + m2.toString());
final int comparison = m1.getName().compareTo(m2.getName());
if (comparison != 0) {
return comparison;
}
return m1.toString().compareTo(m2.toString());
}
};

private static int compare(String s1, String s2) {
return s1.compareTo(s2);
}

/**
* Gets declared methods of a class in a predictable order, unless @FixMethodOrder(MethodSorters.JVM) is specified.
Expand Down

0 comments on commit ec7fd69

Please sign in to comment.