1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 10:03:22 +03:00
juvix/test/Internal/Eval/Positive.hs

193 lines
5.2 KiB
Haskell
Raw Normal View History

module Internal.Eval.Positive where
import Base
import Internal.Eval.Base
data PosTest = PosTest
{ _name :: String,
2022-12-20 15:05:40 +03:00
_relDir :: Path Rel Dir,
_file :: Path Rel File,
_expectedFile :: Path Rel File
}
2022-12-20 15:05:40 +03:00
root :: Path Abs Dir
root = relToProject $(mkRelDir "tests/Internal/positive")
2022-12-20 15:05:40 +03:00
coreRoot :: Path Abs Dir
coreRoot = relToProject $(mkRelDir "tests/Internal/Core/positive")
2022-12-20 15:05:40 +03:00
testDescr :: Path Abs Dir -> PosTest -> TestDescr
testDescr r PosTest {..} =
2022-12-20 15:05:40 +03:00
let tRoot = r <//> _relDir
file' = tRoot <//> _file
expected' = tRoot <//> _expectedFile
in TestDescr
{ _testName = _name,
_testRoot = tRoot,
2022-12-20 15:05:40 +03:00
_testAssertion = Steps $ internalCoreAssertion file' expected'
}
allTests :: TestTree
allTests =
testGroup
"Internal to Core positive tests"
(map (mkTest . testDescr root) tests ++ map (mkTest . testDescr coreRoot) coreTests)
coreTests :: [PosTest]
coreTests =
[ PosTest
"If then else"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test006.juvix")
$(mkRelFile "out/test006.out"),
PosTest
"Fibonacci"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test011.juvix")
$(mkRelFile "out/test011.out")
]
tests :: [PosTest]
tests =
[ PosTest
"An integer literal"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "IntegerLiteral.juvix")
$(mkRelFile "out/IntegerLiteral.out"),
PosTest
"A zero argument function"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "IdenFunctionIntegerLiteral.juvix")
$(mkRelFile "out/IdenFunctionIntegerLiteral.out"),
PosTest
"A two argument function"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "IdenFunctionArgs.juvix")
$(mkRelFile "out/IdenFunctionArgs.out"),
PosTest
"A function with implicit arguments"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "IdenFunctionArgsImplicit.juvix")
$(mkRelFile "out/IdenFunctionArgsImplicit.out"),
PosTest
"A module that imports another"
2022-12-20 15:05:40 +03:00
$(mkRelDir "Import")
$(mkRelFile "Importer.juvix")
$(mkRelFile "out/Importer.out"),
PosTest
"A constructor valued function"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "FunctionReturnConstructor.juvix")
$(mkRelFile "out/FunctionReturnConstructor.out"),
PosTest
"Pattern matching on a constructor"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "MatchConstructor.juvix")
$(mkRelFile "out/MatchConstructor.out"),
PosTest
"Pattern matching Nat under suc"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "NatMatch1.juvix")
$(mkRelFile "out/NatMatch1.out"),
PosTest
"Pattern matching Nat as binder"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "NatMatch2.juvix")
$(mkRelFile "out/NatMatch2.out"),
PosTest
"Literal Nat"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "LitInteger.juvix")
$(mkRelFile "out/LitInteger.out"),
PosTest
"Pattern matching on literal Nat"
$(mkRelDir ".")
$(mkRelFile "LitIntegerToNat.juvix")
$(mkRelFile "out/LitIntegerToNat.out"),
PosTest
"Literal String"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "LitString.juvix")
$(mkRelFile "out/LitString.out"),
PosTest
"Literal String IO"
$(mkRelDir ".")
$(mkRelFile "LitStringIO.juvix")
$(mkRelFile "out/LitStringIO.out"),
PosTest
"Mutually defined functions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "Mutual.juvix")
$(mkRelFile "out/Mutual.out"),
PosTest
"Calling builtin addition"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "BuiltinAdd.juvix")
$(mkRelFile "out/BuiltinAdd.out"),
PosTest
"Builtin bool"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "BuiltinBool.juvix")
$(mkRelFile "out/BuiltinBool.out"),
PosTest
"Builtin if"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "BuiltinIf.juvix")
$(mkRelFile "out/BuiltinIf.out"),
PosTest
"Lambda"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "Lambda.juvix")
$(mkRelFile "out/Lambda.out"),
PosTest
"Pattern args"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "PatternArgs.juvix")
$(mkRelFile "out/PatternArgs.out"),
PosTest
"QuickSort"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "QuickSort.juvix")
$(mkRelFile "out/QuickSort.out"),
PosTest
"Universe"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "Universe.juvix")
$(mkRelFile "out/Universe.out"),
PosTest
"Inductive type constructor"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "Inductive.juvix")
$(mkRelFile "out/Inductive.out"),
PosTest
"Function type"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "FunctionType.juvix")
$(mkRelFile "out/FunctionType.out"),
PosTest
"Builtin Inductive type"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "BuiltinInductive.juvix")
$(mkRelFile "out/BuiltinInductive.out"),
PosTest
"Higher Order Lambda"
$(mkRelDir ".")
$(mkRelFile "HigherOrderLambda.juvix")
$(mkRelFile "out/HigherOrderLambda.out"),
PosTest
"Type Aliases"
$(mkRelDir ".")
$(mkRelFile "Church.juvix")
$(mkRelFile "out/Church.out"),
PosTest
"Nested as patterns"
$(mkRelDir ".")
$(mkRelFile "AsPatterns.juvix")
$(mkRelFile "out/AsPatterns.out"),
PosTest
"Case expression"
$(mkRelDir ".")
$(mkRelFile "Case.juvix")
$(mkRelFile "out/Case.out")
]