gpt4 book ai didi

f# - 单元测试 : '[] |> should equal List.empty' is not working as expected

转载 作者:行者123 更新时间:2023-12-02 05:41:03 24 4
gpt4 key购买 nike

我有以下代码,但测试失败:

open Xunit
open FsUnit.Xunit

let rec openOrSenior xs =
match xs with
| head :: tail when fst head >= 55 && snd head >= 7 -> "Senior" :: openOrSenior tail
| head :: tail -> "Open" :: openOrSenior tail
| [] -> []

[<Fact>]
let ``empty input gives empty result``() =
openOrSenior [] |> should equal List.empty

测试失败,出现以下匹配错误

FsUnit.Xunit+MatchException : Exception of type 'FsUnit.Xunit+MatchException' was thrown. Expected: Equals []
Actual: was []

最佳答案

equal在 FsUnit 中做了一些奇特的匹配是 be只是身份函数。
Here is the link source

如果您使用:

|> should be Empty

关于f# - 单元测试 : '[] |> should equal List.empty' is not working as expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36939714/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com