on master help sign in
Update helper functions in Test.Compiler to align with new signature for Compiler.compile.

In particular, accomodate the following changes to Compiler.compile: * New parameter isRoot :: Bool * Return value of type ([Warning], Either [Error] (PublicModule.Interface, String)), rather than Either String (PublicModule.Interface, String).

commit9087bb7027546a1eaa606246006179ef927fca7a authorJustin Manley <manleyjster@gmail.com> dateTue 19 May 2015, 22:44 (11 years ago) parent0537abb
3 files changed+11−12
elm-compiler.cabal+1−1 tests/Test/Compiler.hs+9−10 tests/Test/Property.hs+1−1
elm-compiler.cabal+1−1
@@ -186,7 +186,7 @@ Test-Suite compiler-tests
186186 Test.Property.Arbitrary
187187 AST.Helpers
188188 AST.Literal
189− AST.PrettyPrint
189+ Reporting.PrettyPrint
190190
191191 build-depends:
192192 test-framework > 0.8 && < 0.9,
tests/Test/Compiler.hs+9−10
@@ -14,7 +14,6 @@ import Test.HUnit (Assertion, assertFailure, assertBool)
1414import qualified Elm.Compiler as Compiler
1515import qualified Elm.Compiler.Module as Module
1616
17−
1817compilerTests :: Test
1918compilerTests =
2019 buildTest $ do
@@ -45,7 +44,7 @@ testsDir =
4544-- RUN COMPILER
4645
4746testIf
48− :: (Either String (Module.Interface, String) -> Assertion)
47+ :: (([Compiler.Warning], Either [Compiler.Error] (Module.Interface, String)) -> Assertion)
4948 -> [FilePath]
5049 -> IO [Test]
5150testIf handleResult filePaths =
@@ -53,21 +52,21 @@ testIf handleResult filePaths =
5352 where
5453 setupTest filePath =
5554 do source <- readFile filePath
56− let result = Compiler.compile "elm-lang" "core" source Map.empty
55+ let result = Compiler.compile "elm-lang" "core" True source Map.empty
5756 return (testCase filePath (handleResult result))
5857
5958
6059-- CHECK RESULTS
6160
62−isSuccess :: Either String a -> Assertion
63−isSuccess result =
61+isSuccess :: ([Compiler.Warning], Either [Compiler.Error] a) -> Assertion
62+isSuccess (_, result) =
6463 case result of
65− Right _ -> assertBool "" True
66− Left msg -> assertFailure msg
64+ Right _ -> assertBool "" True
65+ Left errors -> assertFailure $ (unlines $ map (Compiler.errorToString "" "") errors)
6766
6867
69−isFailure :: Either a b -> Assertion
70−isFailure result =
68+isFailure :: ([Compiler.Warning], Either a b) -> Assertion
69+isFailure (_, result) =
7170 case result of
7271 Right _ -> assertFailure "Compilation succeeded but should have failed"
73− Left _ -> assertBool "" True
72+ Left _ -> assertBool "" True
tests/Test/Property.hs+1−1
@@ -12,7 +12,7 @@ import Text.PrettyPrint as P
1212import AST.Literal as Lit
1313import qualified AST.Pattern as P
1414import qualified AST.Variable as V
15−import AST.PrettyPrint (Pretty, pretty)
15+import Reporting.PrettyPrint (Pretty, pretty)
1616import Parse.Helpers (IParser, iParse)
1717import Parse.Literal (literal)
1818import qualified Parse.Pattern as Pat (expr)