on master help sign in
Update helper functions in Test.Compiler to align with new signature for Compiler.compile.
9087bb7Justin Manley
elm-compiler.cabal+1−1
@@ -186,7 +186,7 @@ Test-Suite compiler-tests
186 Test.Property.Arbitrary
186 Test.Property.Arbitrary
187 AST.Helpers
187 AST.Helpers
188 AST.Literal
188 AST.Literal
189− AST.PrettyPrint
189+ Reporting.PrettyPrint
190
190
191 build-depends:
191 build-depends:
192 test-framework > 0.8 && < 0.9,
192 test-framework > 0.8 && < 0.9,
tests/Test/Compiler.hs+9−10
@@ -14,7 +14,6 @@ import Test.HUnit (Assertion, assertFailure, assertBool)
14import qualified Elm.Compiler as Compiler
14import qualified Elm.Compiler as Compiler
15import qualified Elm.Compiler.Module as Module
15import qualified Elm.Compiler.Module as Module
16
16
17−
18compilerTests :: Test
17compilerTests :: Test
19compilerTests =
18compilerTests =
20 buildTest $ do
19 buildTest $ do
@@ -45,7 +44,7 @@ testsDir =
45-- RUN COMPILER
44-- RUN COMPILER
46
45
47testIf
46testIf
48− :: (Either String (Module.Interface, String) -> Assertion)
47+ :: (([Compiler.Warning], Either [Compiler.Error] (Module.Interface, String)) -> Assertion)
49 -> [FilePath]
48 -> [FilePath]
50 -> IO [Test]
49 -> IO [Test]
51testIf handleResult filePaths =
50testIf handleResult filePaths =
@@ -53,21 +52,21 @@ testIf handleResult filePaths =
53 where
52 where
54 setupTest filePath =
53 setupTest filePath =
55 do source <- readFile filePath
54 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
57 return (testCase filePath (handleResult result))
56 return (testCase filePath (handleResult result))
58
57
59
58
60-- CHECK RESULTS
59-- CHECK RESULTS
61
60
62−isSuccess :: Either String a -> Assertion
61+isSuccess :: ([Compiler.Warning], Either [Compiler.Error] a) -> Assertion
63−isSuccess result =
62+isSuccess (_, result) =
64 case result of
63 case result of
65− Right _ -> assertBool "" True
64+ Right _ -> assertBool "" True
66− Left msg -> assertFailure msg
65+ Left errors -> assertFailure $ (unlines $ map (Compiler.errorToString "" "") errors)
67
66
68
67
69−isFailure :: Either a b -> Assertion
68+isFailure :: ([Compiler.Warning], Either a b) -> Assertion
70−isFailure result =
69+isFailure (_, result) =
71 case result of
70 case result of
72 Right _ -> assertFailure "Compilation succeeded but should have failed"
71 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
12import AST.Literal as Lit
12import AST.Literal as Lit
13import qualified AST.Pattern as P
13import qualified AST.Pattern as P
14import qualified AST.Variable as V
14import qualified AST.Variable as V
15−import AST.PrettyPrint (Pretty, pretty)
15+import Reporting.PrettyPrint (Pretty, pretty)
16import Parse.Helpers (IParser, iParse)
16import Parse.Helpers (IParser, iParse)
17import Parse.Literal (literal)
17import Parse.Literal (literal)
18import qualified Parse.Pattern as Pat (expr)
18import qualified Parse.Pattern as Pat (expr)