Created
August 11, 2015 15:28
-
-
Save siordache/a6f5b05d5c819cd825b6 to your computer and use it in GitHub Desktop.
A Spock specification that fails in Java 8 with CGLIB 3.1 but works with CGLIB 3.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Range<T extends Number> implements Comparable<Range<T>> { | |
private final T minVal; | |
private final T maxVal; | |
public Range(T minVal, T maxVal) { | |
this.minVal = minVal; | |
this.maxVal = maxVal; | |
} | |
@Override | |
public int compareTo(Range<T> other) { | |
double myLen = maxVal.doubleValue() - minVal.doubleValue(); | |
double otherLen = other.maxVal.doubleValue() - other.minVal.doubleValue(); | |
return Double.compare(myLen, otherLen); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spock.lang.Specification | |
class RangeSpec extends Specification { | |
def "compare ranges"() { | |
given: | |
Range<Integer> range1 = Spy(constructorArgs: [3, 5]) | |
Range<Integer> range2 = Spy(constructorArgs: [2, 6]) | |
expect: | |
range1.compareTo(range2) < 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment