1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 00:44:57 +03:00

Evaluate closed terms.

This commit is contained in:
Rob Rix 2019-12-20 11:04:42 -05:00
parent 8894d73bbb
commit 540b88c5a0
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -37,6 +37,7 @@ import Source.Span
import Streaming
import qualified Streaming.Process
import Syntax.Term
import Syntax.Var (closed)
import System.Directory
import System.Exit
import System.Path ((</>))
@ -91,7 +92,8 @@ assertJQExpressionSucceeds directive tree core = do
assertEvaluatesTo :: Term (Ann Span :+: Core) Name -> Text -> Concrete (Term (Ann Span :+: Core)) -> HUnit.Assertion
assertEvaluatesTo core k val = do
prelude <- parsePrelude
let allTogether = (named' "__semantic_prelude" :<- prelude) >>>= core
let withPrelude = (named' "__semantic_prelude" :<- prelude) >>>= core
allTogether <- maybe (HUnit.assertFailure ("Cant evaluate open term: " <> showCore (stripAnnotations withPrelude))) pure (closed withPrelude)
let filius = [File (Path.absRel "<interactive>") (Span (Pos 1 1) (Pos 1 1)) allTogether]
(heap, env) <- case Concrete.concrete Eval.eval filius of