@@ -19,6 +19,8 @@ import Test.HUnit (Assertion, assertFailure, assertBool, assertEqual)
19import qualified Elm.Compiler as Compiler
19import qualified Elm.Compiler as Compiler
20import qualified Elm.Package as Package
20import qualified Elm.Package as Package
22writeExpectedJsEnvVarName :: String
24writeExpectedJsEnvVarName :: String
23writeExpectedJsEnvVarName =
25writeExpectedJsEnvVarName =
24 "ELM_WRITE_NEW_EXPECTED"
26 "ELM_WRITE_NEW_EXPECTED"
@@ -38,8 +40,10 @@ compilerTests =
41-- GATHER FILES
44-- GATHER FILES
43getElms :: FilePath -> IO [FilePath]
47getElms :: FilePath -> IO [FilePath]
44getElms filePath =
48getElms filePath =
@@ -54,14 +58,16 @@ testsDir =
55convertToExpectedJsFilePath :: String -> FilePath -> FilePath
59convertToExpectedJsFilePath :: String -> FilePath -> FilePath
56convertToExpectedJsFilePath expectedJsDir filePath =
60convertToExpectedJsFilePath expectedJsDir filePath =
58 </> expectedJsDir
62 </> expectedJsDir
59 </> joinPath (drop 3 (splitDirectories filePath))
63 </> joinPath (drop 3 (splitDirectories filePath))
63-- TEST HELPERS
68-- TEST HELPERS
65compileString :: FilePath -> String -> Either String Compiler.Result
71compileString :: FilePath -> String -> Either String Compiler.Result
66compileString filePath source =
72compileString filePath source =
67 let context =
73 let context =
@@ -85,8 +91,10 @@ readFileOrErrorStr filePath =
85 return (show e)
91 return (show e)
88-- RUN TESTS
95-- RUN TESTS
91 :: (Either String Compiler.Result -> Assertion)
99 :: (Either String Compiler.Result -> Assertion)
92 -> [FilePath]
100 -> [FilePath]
@@ -143,8 +151,10 @@ testMatchesExpected elmDir expectedJsDir =
143 traverse (doMatchesExpectedTest expectedJsDir) elmFiles
151 traverse (doMatchesExpectedTest expectedJsDir) elmFiles
146-- CHECK RESULTS
155-- CHECK RESULTS
148isSuccess :: Either String a -> Assertion
158isSuccess :: Either String a -> Assertion
149isSuccess result =
159isSuccess result =
150 case result of
160 case result of