FsCheck NUnit. Conditional tests
I am trying to check for this function
let extract_one_rule (rule:Rule.t<'a,'b>) =
let rec expand = function
|PAlt (a,b) -> expand a @ expand b
|PSeq (a,b) -> let wrap = List.map (fun x -> (x.rule, fun r -> {x with rule = r})) a
|> List.unzip
in
let rec gen = function
| hd::tl -> [for x in hd -> x :: ( gen tl |> List.concat)]
| [] -> []
in
fst wrap |> List.map expand |> gen
|> List.map (fun x -> PSeq ((List.map2 ( |> ) x (snd wrap)),b))
|PRef _
|PLiteral _
|PToken _ as t -> [t]
| _ -> (System.Console.WriteLine("incorrect tree for alternative expanding!")
; failwith "incorrect tree for alternative expanding!")
in
expand rule.body |> List.map (fun x -> {rule with body = x})
using FsCheck so I have this
let ExpandAlterTest(t : Rule.t<Source.t,Source.t> ) = convertToMeta t |> List.forall (fun x -> ruleIsAfterEBNF x)
but I see the exception "wrong tree for alternate extension!" but when i use smth like this
let ExpandAlterTest(t : Rule.t<Source.t,Source.t> ) = (correctForAlExp t.body) ==> lazy ( convertToMeta t |> List.forall (fun x -> ruleIsAfterEBNF x))
NUnit won't stop working Why might this be?
a source to share
Maybe the precondition you added is very restrictive, so it takes a long time until a good value is found (which actually passes the precondition). FsCheck is fierce against this - by default it tries to find 100 values, but when it rejected 1000 it gave up and you will see the result "Arguments exhausted after x tests". But it can take a long time if generating and validating the value takes a long time.
It could also be that you have an error somewhere like an infinite loop.
Try changing your FsCheck configuration to run fewer tests, verbose run (verboseCheck), and hack the debugger when it seems to hang.
a source to share