File tree 2 files changed +7
-4
lines changed
main/kotlin/au/com/dius/pact/core/matchers
test/groovy/au/com/dius/pact/core/matchers
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ fun matchDecimal(actual: Any?): Boolean {
239
239
actual == 0 -> true
240
240
actual is Float -> true
241
241
actual is Double -> true
242
- actual is BigDecimal && actual.precision () > 0 -> true
242
+ actual is BigDecimal && ( actual == BigDecimal . ZERO || actual.scale () > 0 ) -> true
243
243
actual is JsonPrimitive && actual.isNumber -> decimalRegex.matches(actual.toString())
244
244
else -> false
245
245
}
@@ -252,7 +252,7 @@ fun matchInteger(actual: Any?): Boolean {
252
252
actual is Int -> true
253
253
actual is Long -> true
254
254
actual is BigInteger -> true
255
- actual is BigDecimal && actual.precision () == 0 -> true
255
+ actual is BigDecimal && actual.scale () == 0 -> true
256
256
actual is JsonPrimitive && actual.isNumber -> integerRegex.matches(actual.toString())
257
257
else -> false
258
258
}
Original file line number Diff line number Diff line change @@ -212,7 +212,9 @@ class MatcherExecutorSpec extends Specification {
212
212
100 as int | true
213
213
100 as long | true
214
214
100 as BigInteger | true
215
-
215
+ 100 as BigDecimal | true
216
+ BigInteger . ZERO | true
217
+ BigDecimal . ZERO | true
216
218
}
217
219
218
220
@Unroll
@@ -232,7 +234,8 @@ class MatcherExecutorSpec extends Specification {
232
234
100 as int | false
233
235
100 as long | false
234
236
100 as BigInteger | false
235
-
237
+ BigInteger . ZERO | false
238
+ BigDecimal . ZERO | true
236
239
}
237
240
238
241
}
You can’t perform that action at this time.
0 commit comments