1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-25 08:34:10 +03:00
juvix/test/Compilation/Base.hs

23 lines
807 B
Haskell
Raw Normal View History

module Compilation.Base where
import Base
import Data.HashMap.Strict qualified as HashMap
import Juvix.Compiler.Builtins (iniState)
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
import Juvix.Compiler.Core.Translation.FromInternal.Data qualified as Core
import Juvix.Compiler.Pipeline
compileAssertion ::
Path Abs File ->
Path Abs File ->
(String -> IO ()) ->
Assertion
compileAssertion mainFile _ step = do
step "Translate to JuvixCore"
cwd <- getCurrentDir
let entryPoint = defaultEntryPoint cwd mainFile
tab <- (^. Core.coreResultTable) . snd <$> runIO' iniState entryPoint upToCore
case (tab ^. Core.infoMain) >>= ((tab ^. Core.identContext) HashMap.!?) of
Just _ -> return ()
Nothing -> assertFailure ("No main function registered in: " <> toFilePath mainFile)