@@ -170,18 +170,21 @@ class KotestJavaArbitraryGeneratorSet(
170
170
var min = decimalConstraint.min?.toDouble() ? : - Double .MAX_VALUE
171
171
var max = decimalConstraint.max?.toDouble() ? : Double .MAX_VALUE
172
172
173
- if (decimalConstraint.minInclusive == false ) {
174
- min + = Double .MIN_VALUE
175
- }
176
- if (decimalConstraint.maxInclusive ? : true ) {
177
- if (max != Double .MAX_VALUE ) {
178
- max + = Double .MIN_VALUE
179
- }
180
- }
181
-
182
- if (min == max) {
173
+ if (min == max &&
174
+ (decimalConstraint.minInclusive ? : true ) &&
175
+ (decimalConstraint.maxInclusive ? : true )
176
+ ) {
183
177
Arb .constant(min)
184
178
} else {
179
+ if (decimalConstraint.minInclusive == false ) {
180
+ min + = Double .MIN_VALUE
181
+ }
182
+ if (decimalConstraint.maxInclusive ? : true ) {
183
+ if (max != Double .MAX_VALUE ) {
184
+ max + = Double .MIN_VALUE
185
+ }
186
+ }
187
+
185
188
Arb .double(min = min, max = max)
186
189
}.map { if (scale != null ) it.ofScale(scale) else it }
187
190
.single()
@@ -200,18 +203,21 @@ class KotestJavaArbitraryGeneratorSet(
200
203
var min = decimalConstraint.min?.toFloat() ? : - Float .MAX_VALUE
201
204
var max = decimalConstraint.max?.toFloat() ? : Float .MAX_VALUE
202
205
203
- if (decimalConstraint.minInclusive == false ) {
204
- min + = Float .MIN_VALUE
205
- }
206
- if (decimalConstraint.maxInclusive ? : true ) {
207
- if (max != Float .MAX_VALUE ) {
208
- max + = Float .MIN_VALUE
209
- }
210
- }
211
-
212
- if (min == max) {
206
+ if (min == max &&
207
+ (decimalConstraint.minInclusive ? : true ) &&
208
+ (decimalConstraint.maxInclusive ? : true )
209
+ ) {
213
210
Arb .constant(min)
214
211
} else {
212
+ if (decimalConstraint.minInclusive == false ) {
213
+ min + = Float .MIN_VALUE
214
+ }
215
+ if (decimalConstraint.maxInclusive ? : true ) {
216
+ if (max != Float .MAX_VALUE ) {
217
+ max + = Float .MIN_VALUE
218
+ }
219
+ }
220
+
215
221
Arb .float(min = min, max = max)
216
222
}.map { if (scale != null ) it.ofScale(scale) else it }
217
223
.single()
@@ -326,18 +332,21 @@ class KotestJavaArbitraryGeneratorSet(
326
332
var min = decimalConstraint.min ? : BigDecimal .valueOf(- Double .MAX_VALUE )
327
333
var max = decimalConstraint.max ? : BigDecimal .valueOf(Double .MAX_VALUE )
328
334
329
- if (decimalConstraint.minInclusive == false ) {
330
- min = min.add(BigDecimal .valueOf(Double .MIN_VALUE ))
331
- }
332
- if (decimalConstraint.maxInclusive ? : true ) {
333
- if (max != BigDecimal .valueOf(Double .MAX_VALUE )) {
334
- max + = max.add(BigDecimal .valueOf(Double .MIN_VALUE ))
335
- }
336
- }
337
-
338
- if (min.compareTo(max) == 0 ) {
335
+ if (min.compareTo(max) == 0 &&
336
+ (decimalConstraint.minInclusive ? : true ) &&
337
+ (decimalConstraint.maxInclusive ? : true )
338
+ ) {
339
339
Arb .constant(min)
340
340
} else {
341
+ if (decimalConstraint.minInclusive == false ) {
342
+ min = min.add(BigDecimal .valueOf(Double .MIN_VALUE ))
343
+ }
344
+ if (decimalConstraint.maxInclusive ? : true ) {
345
+ if (max != BigDecimal .valueOf(Double .MAX_VALUE )) {
346
+ max = max.add(BigDecimal .valueOf(Double .MIN_VALUE ))
347
+ }
348
+ }
349
+
341
350
Arb .bigDecimal(min = min, max = max)
342
351
}.map { if (scale != null ) it.setScale(scale, RoundingMode .DOWN ) else it }
343
352
.single()
0 commit comments