@@ -18,7 +18,10 @@ 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+import qualified AST.Module as Module
22+import qualified AST.Module.Name as ModuleName
23+import qualified AST.Variable as Variable
24+import qualified AST.Type as Type
24writeExpectedJsEnvVarName :: String
27writeExpectedJsEnvVarName :: String
@@ -68,12 +71,40 @@ convertToExpectedJsFilePath expectedJsDir filePath =
68-- TEST HELPERS
71-- TEST HELPERS
74+essentialInterfaces :: Module.Interfaces
78+ (ModuleName.inCore ["Debug"],
81+ ("crash", Type.Lambda (Type.Var "String") (Type.Var "a"))
87+buildCoreInterface :: [(String, Type.Canonical)] -> Module.Interface
88+buildCoreInterface members =
89+ let exports = map (Variable.Value . fst) members
91+ types = Map.fromList members
97+ Module.Interface Compiler.version Package.coreName exports types imports adts aliases fixities ports
71compileString :: FilePath -> String -> Either String Compiler.Result
100compileString :: FilePath -> String -> Either String Compiler.Result
72compileString filePath source =
101compileString filePath source =
102+ let dependentModuleNames =
103+ Map.keys essentialInterfaces
73− let context =
104+ context =
74− Compiler.Context Package.coreName True False []
105+ Compiler.Context Package.coreName True False dependentModuleNames
75 (dealiaser, _warnings, result) =
106 (dealiaser, _warnings, result) =
76− Compiler.compile context source Map.empty
107+ Compiler.compile context source essentialInterfaces
77 formatErrors errors =
108 formatErrors errors =
78 concatMap (Compiler.errorToString dealiaser filePath source) errors
109 concatMap (Compiler.errorToString dealiaser filePath source) errors