我是F#的新手,我正在玩FParsec。我會使用FParsec來生成一個AST。我想使用FsUnit在解析器的各個部分編寫一些測試以確保正確的操作。 我有一點麻煩的語法(對不起,確切的代碼是在工作中,我可以在以後發佈一個具體的例子),所以究竟能一個比較兩個識別聯合(一個預期,其他的實際結果)?有人可以使用FsUnit(或NUnit)提供一個很小的代碼示例嗎? 一個例子識別聯合(很簡單) type
我想檢查我的函數返回Some(x) testedFunc() |> should be (sameAs Some)
testedFunc() |> should be Some
testedFunc() |> should equal Some
所有不起作用。我寧可不使用: match testedFunc() with
| Some -> Pass()
| None
我開始使用FsUnit來測試F#代碼。它可以表達F#風格的斷言,例如: [<Test>]
member this.``Portugal voted for 23 countries in 2001 Eurovision contest``() =
this.totalVotes
|> getYearVotesFromCountry "Portugal" 2001
|
我複製從FsUnit project page這個例子: open NUnit.Framework
open FsUnit
let [<Test>] trivial() = 1 |> should not (equal 2)
F#給我以下錯誤: Error 2 This expression was expected to have type bool but here has type
我們正在使用美妙的FSUnit進行單元測試。這工作正常,除了我們測試的主體堅持使用完整的F#語法(在每行的結尾處使用'in')而不是#light語法。例如: module MyTests
open System
open NUnit.Framework
open FsUnit
open MyModule
[<TestFixture>]
type ``Given a valid fi