@@ -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
18compilerTests :: Test
17compilerTests :: Test
19compilerTests =
18compilerTests =
20 buildTest $ do
19 buildTest $ do
@@ -45,7 +44,7 @@ testsDir =
45-- RUN COMPILER
44-- RUN COMPILER
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 =
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))
60-- CHECK RESULTS
59-- CHECK RESULTS
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)
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