bool类型与Constraints.constraint类型不兼容

时间:2015-11-11 04:35:51

标签: f#

我做了以下课程:

type numbers(Roman:string, CommonNumber:string)=
          member this.RomanNumber=Roman
          member this.ExpectedNumber=CommonNumber

          member this.MakeComparision()=
                           string (convert(Roman))= CommonNumber

然后我尝试对它运行以下测试:

#if INTERACTIVE
#r @"..\packages\NUnit.2.6.4\lib\nunit.framework.dll"
#r @"..\packages\FsUnit.1.4.0.0\lib\net45\FsUnit.NUnit.dll"
#endif


    open NUnit.Framework
    open FsUnit


[<TestFixture>]

    type ``Given a Roman number ``()=
         let setNumbers=new numbers("XCIX","99")


         [<Test>]

         member this.
               ``Whether the right convert for this number must be exist``()=
                 setNumbers.MakeComparision() |> should be true

在最后一行setNumbers.MakeComparision() |> should be true,关于字true,我有以下错误:

The type bool in not compatible with type Constraints.constraint

我无法处理!!

1 个答案:

答案 0 :(得分:1)

哦,这是一个令人讨厌的(经常摔倒)

您需要将equaltrue 一起使用:

member this.
       ``Whether the right convert for this number must be exist``()=
         setNumbers.MakeComparision() 
         |> should equal true

或者您需要将True 约束be一起使用:

member this.
       ``Whether the right convert for this number must be exist``()=
         setNumbers.MakeComparision() 
         |> should be True

请参阅documentation