Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 检查一下努尼特。有条件的测试_F#_Nunit_Fscheck - Fatal编程技术网

F# 检查一下努尼特。有条件的测试

F# 检查一下努尼特。有条件的测试,f#,nunit,fscheck,F#,Nunit,Fscheck,我正在尝试对这个函数进行测试 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

我正在尝试对这个函数进行测试

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})
让我们提取一条规则(规则:rule.t)=
让rec展开=函数
|PAlt(a,b)->扩展a@扩展b
|PSeq(a,b)->让wrap=List.map(funx->(x.rule,funr->{x with rule=r}))a
|>List.unzip
在里面
设rec gen=函数
|hd::tl->[对于hd中的x->x::(gen tl |>List.concat)]
| []     -> []
在里面
fst wrap |>List.map expand |>gen
|>List.map(funx->PSeq((List.map2(|>)x(snd-wrap)),b))
|优先股
|上肢_
|PToken作为t->[t]
|->(System.Console.WriteLine(“可选扩展的树不正确!”)
;failwith“备选扩展的树不正确!”)
在里面
展开rule.body |>List.map(funx->{rule with body=x})
使用FsCheck 所以我有这个

let ExpandAlterTest(t : Rule.t<Source.t,Source.t> ) = convertToMeta t |> List.forall (fun x -> ruleIsAfterEBNF x)
let ExpandAlterTest(t:Rule.t)=convertToMeta t |>List.forall(fun x->ruleIsAfterEBNF x)
但我会看到异常“替代扩展的错误树!” 但是当我像那样使用smth时

let ExpandAlterTest(t : Rule.t<Source.t,Source.t> ) = (correctForAlExp t.body) ==> lazy ( convertToMeta t |> List.forall (fun x -> ruleIsAfterEBNF x))
let ExpandAlterTest(t:Rule.t)=(correctortforalexp t.body)=>lazy(convertToMeta t |>List.forall(fun x->ruleIsAfterEBNF x))
NUnit没有停止工作
为什么会这样?

可能是您添加的前提条件非常严格,因此需要很长时间才能找到一个好的值(实际通过前提条件的值)。FsCheck对此进行了强化—默认情况下,它会尝试查找100个值,但当它拒绝1000个值时,它就会放弃,您应该会看到“x测试后参数耗尽”输出。但是,如果生成和检查值需要很长时间,那么这可能需要很长时间

也可能是你实际上在某个地方有一个bug,比如一个无限循环

尝试更改FsCheck配置以运行较少的测试,执行详细运行(verboseCheck),并在调试器似乎挂起时中断调试器