File tree Expand file tree Collapse file tree 3 files changed +30
-16
lines changed
jruby-gradle-base-plugin/src
main/groovy/com/github/jrubygradle/internal
test/groovy/com/github/jrubygradle/internal Expand file tree Collapse file tree 3 files changed +30
-16
lines changed Original file line number Diff line number Diff line change 1
1
language : groovy
2
2
sudo : false
3
+ addons :
4
+ apt :
5
+ packages :
6
+ - oracle-java8-installer
3
7
4
8
install :
5
9
- ./gradlew clean
Original file line number Diff line number Diff line change @@ -169,27 +169,13 @@ class GemVersion {
169
169
return 1
170
170
}
171
171
172
- int aaObject
173
- int bbObject
174
-
175
172
if (aDigits[index]. isInteger() && bDigits[index]. isInteger()) {
176
173
// compare them as number
177
- aaObject = aDigits[index] as int
178
- bbObject = bDigits[index] as int
174
+ aDigits[index] as int <=> bDigits[index] as int
179
175
}
180
176
else {
181
177
// compare them as string
182
- aaObject = aDigits[index]
183
- bbObject = bDigits[index]
184
- }
185
- if (aaObject < bbObject) {
186
- -1
187
- }
188
- else if (aaObject > bbObject) {
189
- 1
190
- }
191
- else {
192
- 0
178
+ aDigits[index] <=> bDigits[index]
193
179
}
194
180
}
195
181
Original file line number Diff line number Diff line change @@ -178,4 +178,28 @@ class GemVersionSpec extends Specification {
178
178
expect :
179
179
subject. intersect(' [1.2.4, 1.2.4]' ). conflict() == true
180
180
}
181
+
182
+ def " finds no conflicts in non-integer version ranges" () {
183
+ given :
184
+ GemVersion subject = new GemVersion (' [1.2.bar, 1.2.foo]' )
185
+
186
+ expect :
187
+ ! subject. conflict()
188
+ }
189
+
190
+ def " finds conflicts in non-integer version ranges" () {
191
+ given :
192
+ GemVersion subject = new GemVersion (' [1.2.foo, 1.2.bar]' )
193
+
194
+ expect :
195
+ subject. conflict()
196
+ }
197
+
198
+ def " does not throw an exception for a '+' version" () {
199
+ when :
200
+ new GemVersion (' +' ). conflict()
201
+
202
+ then :
203
+ notThrown(Exception )
204
+ }
181
205
}
You can’t perform that action at this time.
0 commit comments