Skip to content

Commit 1278886

Browse files
authored
Merge pull request #1778 from jmid/adjust-div-zero-result-top-test
Adjust `test_FI_div_zero_result_top` QCheck test property to account for the 0/0 case
2 parents f2d071f + 34c1199 commit 1278886

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/cdomain/value/cdomains/floatDomain.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ module FloatIntervalImpl(Float_t : CFloatType) = struct
220220
| _ -> Top
221221

222222
(**for QCheck: should describe how to generate random values and shrink possible counter examples *)
223-
let arbitrary () = QCheck.map convert_arb (QCheck.option (QCheck.pair QCheck.float QCheck.float))
223+
let arbitrary () =
224+
let gen = QCheck.map convert_arb (QCheck.option (QCheck.pair QCheck.float QCheck.float)) in
225+
QCheck.set_print show gen
224226

225227
let of_interval' interval =
226228
let x = norm @@ Interval interval

tests/unit/cdomains/floatDomainTest.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ struct
265265

266266
let test_FI_div_zero_result_top =
267267
QCheck.Test.make ~name:"test_FI_div_zero_result_top" (FI.arbitrary ()) (fun arg ->
268-
FI.is_top (FI.div arg (FI.of_const 0.)))
268+
let res = FI.div arg (FI.of_const 0.) in
269+
if FI.equal arg fi_zero
270+
then FI.equal res (FI.nan ())
271+
else FI.is_top res)
269272

270273
let test_FI_accurate_neg =
271274
QCheck.Test.make ~name:"test_FI_accurate_neg" QCheck.float (fun arg ->

0 commit comments

Comments
 (0)