1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-26 09:04:18 +03:00
juvix/test/Tree/Asm/Base.hs
Łukasz Czajka c95fcb38c8
JuvixTree tests (#2587)
* Implements a translation from JuvixAsm to JuvixTree. It does not work
in general, but works for all code generated from Juvix and all JuvixAsm
tests.
* Adds the `juvix dev tree from-asm` command.
* Adds tests automatically converted from JuvixAsm tests.
* Depends on #2583
2024-01-25 18:02:06 +00:00

23 lines
639 B
Haskell

module Tree.Asm.Base where
import Asm.Run.Base qualified as Asm
import Base
import Juvix.Compiler.Asm.Translation.FromTree qualified as Asm
import Juvix.Compiler.Tree.Translation.FromSource
import Juvix.Data.PPOutput
treeAsmAssertion ::
Path Abs File ->
Path Abs File ->
(String -> IO ()) ->
Assertion
treeAsmAssertion mainFile expectedFile step = do
step "Parse"
s <- readFile (toFilePath mainFile)
case runParser (toFilePath mainFile) s of
Left err -> assertFailure (show (pretty err))
Right tabIni -> do
step "Translate"
let tab = Asm.fromTree tabIni
Asm.asmRunAssertion' tab expectedFile step