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#中使用带有Unquote的断言消息?_F#_F# Unquote - Fatal编程技术网

在F#中使用带有Unquote的断言消息?

在F#中使用带有Unquote的断言消息?,f#,f#-unquote,F#,F# Unquote,某些测试断言框架允许您向断言中添加自定义消息,例如使用NUnit添加以下消息: Assert.AreEqual(1, result, "the result should be one") 在F#中使用[Unquote][1]时是否也可以这样做 测试 更新 最接近这一点的是在引用的表达式中添加一个简单的注释。因为我这样做的动机是记录正在被验证的内容(我倾向于不止一次地断言!),这对于我的需要来说是足够的 test <@ // the result

某些测试断言框架允许您向断言中添加自定义消息,例如使用NUnit添加以下消息:

Assert.AreEqual(1, result, "the result should be one")
在F#中使用[Unquote][1]时是否也可以这样做

测试

更新

最接近这一点的是在引用的表达式中添加一个简单的注释。因为我这样做的动机是记录正在被验证的内容(我倾向于不止一次地断言!),这对于我的需要来说是足够的

test <@ 
        // the result should be one
        result = 1 
     @>
测试

您可以这样做(使用F#Interactive)


很明显,使用你建议的变量名方法有很多好处,Stephen。正在努力理解为什么我之前错过了它!:)
test <@ 
        // the result should be one
        result = 1 
     @>
> let result = 2;;
> test <@ ignore "the result should be one"; result = 1 @>;;

Test failed:

ignore "the result should be one"; result = 1
(); result = 1
result = 1
2 = 1
false
> let actual = 2;;
> let expected = 1;;            
> test <@ actual = expected @>;; 

Test failed:

actual = expected
2 = 1
false