diff --git a/.gitignore b/.gitignore index 0021830c..b60caff2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ output/ .output .grin-output/ .vscode/ +*.out + diff --git a/grin/grin.cabal b/grin/grin.cabal index 4abf1c71..f0a26ff2 100644 --- a/grin/grin.cabal +++ b/grin/grin.cabal @@ -232,6 +232,7 @@ executable grin-test , system-posix-redirect , process , bytestring + , MissingH other-modules: Transformations.Simplifying.RegisterIntroductionSpec @@ -316,6 +317,7 @@ executable grin-end-to-end-test , system-posix-redirect , process , bytestring + , MissingH other-modules: Transformations.Simplifying.RegisterIntroductionSpec Transformations.Simplifying.CaseSimplificationSpec diff --git a/grin/test-data/dead-parameter-elimination/pnode.grin.expected b/grin/test-data/dead-parameter-elimination/pnode.grin.expected index 0c1c57ff..df3f50cc 100644 --- a/grin/test-data/dead-parameter-elimination/pnode.grin.expected +++ b/grin/test-data/dead-parameter-elimination/pnode.grin.expected @@ -1,3 +1,4 @@ + grinMain = a0 <- pure (CInt 5) a1 <- pure (CInt 5) @@ -5,34 +6,27 @@ grinMain = p0 <- store a0 p1 <- store a1 p2 <- store a2 - foo3 <- pure (P3foo) pfoo3 <- store foo3 - - foo3ap <- pure (Fap pfoo3 p0) + foo3ap <- pure (Fap pfoo3 p0) pfoo3ap <- store foo3ap - foo2 <- eval pfoo3ap - pfoo2 <- store foo2 - - foo2ap <- pure (Fap pfoo2 p1) + foo2 <- eval $ pfoo3ap + pfoo2 <- store foo2 + foo2ap <- pure (Fap pfoo2 p1) pfoo2ap <- store foo2ap - foo1 <- eval pfoo2ap - pfoo1 <- store foo1 - - foo1ap <- pure (Fap pfoo1 p2) + foo1 <- eval $ pfoo2ap + pfoo1 <- store foo1 + foo1ap <- pure (Fap pfoo1 p2) pfoo1ap <- store foo1ap - fooRet <- eval pfoo1ap - + fooRet <- eval $ pfoo1ap pure fooRet - foo y0 = z0 <- pure (#undefined :: #ptr) x0 <- pure (#undefined :: #ptr) - y0' <- eval y0 + y0' <- eval $ y0 pure y0' --- apply always gets the function node in whnf apply pf cur = case pf of (P3foo) -> @@ -42,31 +36,33 @@ apply pf cur = n1 <- pure (P1foo v0 cur) pure n1 (P1foo v1 v2) -> - n2 <- foo v2 + n2 <- foo $ v2 pure n2 ap f x = - f' <- eval f - apply f' x + f' <- eval $ f + apply $ f' x eval p = v <- fetch p case v of - (CInt n) -> pure v - - (P3foo) -> pure v - (P2foo v3) -> pure v - (P1foo v4 v5) -> pure v - + (CInt n) -> + pure v + (P3foo) -> + pure v + (P2foo v3) -> + pure v + (P1foo v4 v5) -> + pure v (Ffoo b0 b1 b2) -> - w0 <- foo b1 + w0 <- foo $ b1 update p w0 pure w0 (Fapply g y) -> - w1 <- apply g y + w1 <- apply $ g y update p w1 pure w1 (Fap h z) -> - w2 <- ap h z + w2 <- ap $ h z update p w2 pure w2 diff --git a/grin/test-data/dead-parameter-elimination/pnode.grin.opts b/grin/test-data/dead-parameter-elimination/pnode.grin.opts index e69de29b..3bdcd17a 100644 --- a/grin/test-data/dead-parameter-elimination/pnode.grin.opts +++ b/grin/test-data/dead-parameter-elimination/pnode.grin.opts @@ -0,0 +1,3 @@ +- "--quiet" +- "--dpe" +- "--save-grin=$$$OUT$$$" diff --git a/grin/test/Test/Hspec/Compiler.hs b/grin/test/Test/Hspec/Compiler.hs index aa27679b..b0603779 100644 --- a/grin/test/Test/Hspec/Compiler.hs +++ b/grin/test/Test/Hspec/Compiler.hs @@ -20,6 +20,7 @@ import Control.Exception (catch) import qualified Data.Map as Map import Data.Char (isDigit) import Data.List (isSuffixOf) +import Data.String.Utils (replace) import System.Directory @@ -51,7 +52,7 @@ evaluatePipelineTest input options expected params actionWith progressCallback = Binary fp -> [fp, "--load-binary"] Textual fp -> [fp] let outFile = inputToFilePath input <.> "out" - mainWithArgs $ args ++ options ++ ["--save-grin=" ++ outFile] + mainWithArgs $ args ++ (map (replace "$$$OUT$$$" outFile) options) content <- readFile outFile expected <- readFile expected if (content == expected)