mirror of
https://github.com/anoma/juvix.git
synced 2025-01-07 16:22:14 +03:00
a091a7f63d
Builtin information needs to be propagated from stored modules to REPL artifacts to avoid "The builtin _ has not been defined" errors. This PR adds a test suite for the REPL in the Haskell test code. This means some of the slow smoke tests can be moved to fast haskell unit tests. In future we should refactor the REPL code by putting in the main src target and unit testing more features (e.g :doc, :def). * Closes https://github.com/anoma/juvix/issues/2638
22 lines
833 B
Haskell
22 lines
833 B
Haskell
module Repl.Assertions where
|
|
|
|
import Base
|
|
import Juvix.Compiler.Core qualified as Core
|
|
import Juvix.Compiler.Core.Language.Value qualified as Core
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
|
|
|
assertNoJuvixError :: Either JuvixError a -> IO a
|
|
assertNoJuvixError = either (assertFailure . ("JuvixError: " <>) . unpack . renderTextDefault) return
|
|
|
|
assertPrettyCodeEqual :: (Core.PrettyCode a, Eq a) => a -> a -> Assertion
|
|
assertPrettyCodeEqual expected actual = unless (expected == actual) (assertFailure (unpack msg))
|
|
where
|
|
msg :: Text
|
|
msg = "expected: " <> Core.ppTrace expected <> "\n but got: " <> Core.ppTrace actual
|
|
|
|
assertNodeEqual :: Core.Node -> Core.Node -> Assertion
|
|
assertNodeEqual = assertPrettyCodeEqual
|
|
|
|
assertValueEqual :: Core.Value -> Core.Value -> Assertion
|
|
assertValueEqual = assertPrettyCodeEqual
|