@@ -170,18 +170,21 @@ class KotestJavaArbitraryGeneratorSet(
170170 var min = decimalConstraint.min?.toDouble() ? : - Double .MAX_VALUE
171171 var max = decimalConstraint.max?.toDouble() ? : Double .MAX_VALUE
172172
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+ ) {
183177 Arb .constant(min)
184178 } 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+
185188 Arb .double(min = min, max = max)
186189 }.map { if (scale != null ) it.ofScale(scale) else it }
187190 .single()
@@ -200,18 +203,21 @@ class KotestJavaArbitraryGeneratorSet(
200203 var min = decimalConstraint.min?.toFloat() ? : - Float .MAX_VALUE
201204 var max = decimalConstraint.max?.toFloat() ? : Float .MAX_VALUE
202205
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+ ) {
213210 Arb .constant(min)
214211 } 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+
215221 Arb .float(min = min, max = max)
216222 }.map { if (scale != null ) it.ofScale(scale) else it }
217223 .single()
@@ -326,18 +332,21 @@ class KotestJavaArbitraryGeneratorSet(
326332 var min = decimalConstraint.min ? : BigDecimal .valueOf(- Double .MAX_VALUE )
327333 var max = decimalConstraint.max ? : BigDecimal .valueOf(Double .MAX_VALUE )
328334
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+ ) {
339339 Arb .constant(min)
340340 } 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+
341350 Arb .bigDecimal(min = min, max = max)
342351 }.map { if (scale != null ) it.setScale(scale, RoundingMode .DOWN ) else it }
343352 .single()
0 commit comments