Changeset 17b2b6ad680b…
Parent ab91a87e0efb…
by Hao Lian <hao@fogcreek.com>
Changes to 2 files · Browse files at 17b2b6ad680b Showing diff from parent ab91a87e0efb Diff from another changeset...
@@ -6,12 +6,12 @@
open babybearparser.Parser
-let equals actual expected = Assert.AreEqual (expected, actual)
-let throws<'a when 'a :> exn> (f: unit -> unit) =
+let equals actual expected = Assert.IsTrue ((actual = expected), String.Format("{0} <> {1}", actual, expected))
+let throwsParseError (f: unit -> unit) contains =
try
- f(); Assert.Fail ("throws: no exception thrown of type: " + typedefof<'a>.Name)
+ f(); Assert.Fail ("throws: no exception thrown of type ParseError")
with
- | :? 'a -> ()
+ | ParseError(x) -> Assert.IsTrue (x.Contains(contains), String.Format("{0} does not contain {1}", x, contains))
[<TestClass>]
type public Tests () =
@@ -19,7 +19,7 @@ [<TestMethod>]
member this.TestsWorking() =
equals 1 1
-
+
[<TestMethod>]
member this.TestsKeywords() =
equals (parse "foo bar") [KeywordAtom <| Word "foo"; KeywordAtom <| Word "bar"]
@@ -59,8 +59,8 @@ [<TestMethod>]
member this.TestsMissingFilter() =
let f () = parse "\"foo bar\" project:" |> ignore
- throws<ParseError> f
+ throwsParseError f "filter argument"
[<TestMethod>]
member this.TestsUnknownFilter() =
- equals (parse "unknown:careless") [KeywordAtom <| Word "unknown:careless"]
\ No newline at end of file+ equals (parse "unknown:careless") [KeywordAtom <| Word "unknown:careless"]
|
Loading...