-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
92 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Tree.Transformation where | ||
|
||
import Base | ||
import Tree.Transformation.Identity qualified as Identity | ||
|
||
allTests :: TestTree | ||
allTests = | ||
testGroup | ||
"JuvixTree transformations" | ||
[ Identity.allTests | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Tree.Transformation.Base where | ||
|
||
import Base | ||
import Juvix.Compiler.Tree.Data.InfoTable | ||
import Juvix.Compiler.Tree.Transformation | ||
import Tree.Eval.Base | ||
import Tree.Eval.Positive qualified as Eval | ||
|
||
data Test = Test | ||
{ _testTransformations :: [TransformationId], | ||
_testAssertion :: InfoTable -> Assertion, | ||
_testEval :: Eval.PosTest | ||
} | ||
|
||
fromTest :: Test -> TestTree | ||
fromTest = mkTest . toTestDescr | ||
|
||
root :: Path Abs Dir | ||
root = relToProject $(mkRelDir "tests/Tree/positive/") | ||
|
||
toTestDescr :: Test -> TestDescr | ||
toTestDescr Test {..} = | ||
let Eval.PosTest {..} = _testEval | ||
tRoot = root <//> _relDir | ||
file' = tRoot <//> _file | ||
expected' = tRoot <//> _expectedFile | ||
in TestDescr | ||
{ _testName = _name, | ||
_testRoot = tRoot, | ||
_testAssertion = Steps $ treeEvalAssertion file' expected' _testTransformations _testAssertion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Tree.Transformation.Identity (allTests) where | ||
|
||
import Base | ||
import Juvix.Compiler.Tree.Transformation | ||
import Tree.Eval.Positive qualified as Eval | ||
import Tree.Transformation.Base | ||
|
||
allTests :: TestTree | ||
allTests = testGroup "Identity" (map liftTest Eval.tests) | ||
|
||
pipe :: [TransformationId] | ||
pipe = [Identity, IdentityU, IdentityD] | ||
|
||
liftTest :: Eval.PosTest -> TestTree | ||
liftTest _testEval = | ||
fromTest | ||
Test | ||
{ _testTransformations = pipe, | ||
_testAssertion = const (return ()), | ||
_testEval | ||
} |