Unquote raisesWith的第二个参数是什么?

时间:2016-09-04 07:18:56

标签: f# f#-unquote

在非引号userguide中有一个给出的例子,我不明白:

// raisesWith : Expr -> (#exn -> Expr<bool>) -> unit
raisesWith<System.NullReferenceException> <@ ("s":string).Length @> (fun e -> <@ e.ToString() = null @>)

您可以提供一个简短的解释和另一个例子吗?

1 个答案:

答案 0 :(得分:3)

您可以对错误进行断言,如下例所示

raisesWith<DivideByZeroException> <@ 1/0 @> (fun e -> <@ e.Message = "Attempted to divide by zero." @>)
相关问题