on master help sign in
cosmetic: change whitespace a bit
95b4c4dEvan Czaplicki
tests/Test/Compiler.hs+11−1
@@ -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
21
21
22+
23+
22writeExpectedJsEnvVarName :: String
24writeExpectedJsEnvVarName :: String
23writeExpectedJsEnvVarName =
25writeExpectedJsEnvVarName =
24 "ELM_WRITE_NEW_EXPECTED"
26 "ELM_WRITE_NEW_EXPECTED"
@@ -38,8 +40,10 @@ compilerTests =
38 ]
40 ]
39
41
40
42
43+
41-- GATHER FILES
44-- GATHER FILES
42
45
46+
43getElms :: FilePath -> IO [FilePath]
47getElms :: FilePath -> IO [FilePath]
44getElms filePath =
48getElms filePath =
45 find
49 find
@@ -54,14 +58,16 @@ testsDir =
54
58
55convertToExpectedJsFilePath :: String -> FilePath -> FilePath
59convertToExpectedJsFilePath :: String -> FilePath -> FilePath
56convertToExpectedJsFilePath expectedJsDir filePath =
60convertToExpectedJsFilePath expectedJsDir filePath =
57− testsDir
61+ testsDir
58 </> expectedJsDir
62 </> expectedJsDir
59 </> joinPath (drop 3 (splitDirectories filePath))
63 </> joinPath (drop 3 (splitDirectories filePath))
60 <.> ".js"
64 <.> ".js"
61
65
62
66
67+
63-- TEST HELPERS
68-- TEST HELPERS
64
69
70+
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)
86
92
87
93
94+
88-- RUN TESTS
95-- RUN TESTS
89
96
97+
90testIf
98testIf
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
144
152
145
153
154+
146-- CHECK RESULTS
155-- CHECK RESULTS
147
156
157+
148isSuccess :: Either String a -> Assertion
158isSuccess :: Either String a -> Assertion
149isSuccess result =
159isSuccess result =
150 case result of
160 case result of