mirror of
https://github.com/anoma/juvix.git
synced 2024-12-25 00:21:41 +03:00
186f4f66ef
Adds Juvix tests for the compilation pipeline - these are converted from the JuvixCore tests (those that make sense). Currently, only the translation from Juvix to JuvixCore is checked for the tests that can be type-checked. Ultimately, the entire compilation pipeline down to native code / WebAssembly should be checked on these tests. Closes #1689
23 lines
807 B
Haskell
23 lines
807 B
Haskell
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)
|