2022-11-07 16:47:56 +03:00
|
|
|
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-11-07 16:47:56 +03:00
|
|
|
}
|
|
|
|
|
2022-12-20 15:05:40 +03:00
|
|
|
root :: Path Abs Dir
|
|
|
|
root = relToProject $(mkRelDir "tests/Internal/positive")
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2022-12-20 15:05:40 +03:00
|
|
|
coreRoot :: Path Abs Dir
|
|
|
|
coreRoot = relToProject $(mkRelDir "tests/Internal/Core/positive")
|
2022-11-07 16:47:56 +03:00
|
|
|
|
2022-12-20 15:05:40 +03:00
|
|
|
testDescr :: Path Abs Dir -> PosTest -> TestDescr
|
2022-11-07 16:47:56 +03:00
|
|
|
testDescr r PosTest {..} =
|
2022-12-20 15:05:40 +03:00
|
|
|
let tRoot = r <//> _relDir
|
|
|
|
file' = tRoot <//> _file
|
|
|
|
expected' = tRoot <//> _expectedFile
|
2022-11-07 16:47:56 +03:00
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = tRoot,
|
2022-12-20 15:05:40 +03:00
|
|
|
_testAssertion = Steps $ internalCoreAssertion file' expected'
|
2022-11-07 16:47:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Fibonacci"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "test011.juvix")
|
|
|
|
$(mkRelFile "out/test011.out")
|
2022-11-07 16:47:56 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
tests :: [PosTest]
|
|
|
|
tests =
|
|
|
|
[ PosTest
|
|
|
|
"An integer literal"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "IntegerLiteral.juvix")
|
|
|
|
$(mkRelFile "out/IntegerLiteral.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"A zero argument function"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "IdenFunctionIntegerLiteral.juvix")
|
|
|
|
$(mkRelFile "out/IdenFunctionIntegerLiteral.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"A two argument function"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "IdenFunctionArgs.juvix")
|
|
|
|
$(mkRelFile "out/IdenFunctionArgs.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"A function with implicit arguments"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "IdenFunctionArgsImplicit.juvix")
|
|
|
|
$(mkRelFile "out/IdenFunctionArgsImplicit.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"A module that imports another"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir "Import")
|
|
|
|
$(mkRelFile "Importer.juvix")
|
|
|
|
$(mkRelFile "out/Importer.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"A constructor valued function"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "FunctionReturnConstructor.juvix")
|
|
|
|
$(mkRelFile "out/FunctionReturnConstructor.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern matching on a constructor"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "MatchConstructor.juvix")
|
|
|
|
$(mkRelFile "out/MatchConstructor.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern matching Nat under suc"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "NatMatch1.juvix")
|
|
|
|
$(mkRelFile "out/NatMatch1.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern matching Nat as binder"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "NatMatch2.juvix")
|
|
|
|
$(mkRelFile "out/NatMatch2.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
2023-01-03 20:52:20 +03:00
|
|
|
"Literal Nat"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "LitInteger.juvix")
|
|
|
|
$(mkRelFile "out/LitInteger.out"),
|
2023-01-27 18:21:38 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern matching on literal Nat"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "LitIntegerToNat.juvix")
|
|
|
|
$(mkRelFile "out/LitIntegerToNat.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
2023-01-03 20:52:20 +03:00
|
|
|
"Literal String"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "LitString.juvix")
|
|
|
|
$(mkRelFile "out/LitString.out"),
|
2023-01-04 20:02:02 +03:00
|
|
|
PosTest
|
|
|
|
"Literal String IO"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "LitStringIO.juvix")
|
|
|
|
$(mkRelFile "out/LitStringIO.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Mutually defined functions"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Mutual.juvix")
|
|
|
|
$(mkRelFile "out/Mutual.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Calling builtin addition"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "BuiltinAdd.juvix")
|
|
|
|
$(mkRelFile "out/BuiltinAdd.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Builtin bool"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "BuiltinBool.juvix")
|
|
|
|
$(mkRelFile "out/BuiltinBool.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Builtin if"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "BuiltinIf.juvix")
|
|
|
|
$(mkRelFile "out/BuiltinIf.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Lambda"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Lambda.juvix")
|
|
|
|
$(mkRelFile "out/Lambda.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern args"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "PatternArgs.juvix")
|
|
|
|
$(mkRelFile "out/PatternArgs.out"),
|
2022-11-07 16:47:56 +03:00
|
|
|
PosTest
|
|
|
|
"QuickSort"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "QuickSort.juvix")
|
|
|
|
$(mkRelFile "out/QuickSort.out"),
|
2022-11-11 15:38:48 +03:00
|
|
|
PosTest
|
|
|
|
"Universe"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Universe.juvix")
|
|
|
|
$(mkRelFile "out/Universe.out"),
|
2022-11-11 15:38:48 +03:00
|
|
|
PosTest
|
|
|
|
"Inductive type constructor"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Inductive.juvix")
|
|
|
|
$(mkRelFile "out/Inductive.out"),
|
2022-11-11 15:38:48 +03:00
|
|
|
PosTest
|
|
|
|
"Function type"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "FunctionType.juvix")
|
|
|
|
$(mkRelFile "out/FunctionType.out"),
|
2022-11-11 15:38:48 +03:00
|
|
|
PosTest
|
|
|
|
"Builtin Inductive type"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "BuiltinInductive.juvix")
|
2023-01-16 14:13:39 +03:00
|
|
|
$(mkRelFile "out/BuiltinInductive.out"),
|
|
|
|
PosTest
|
|
|
|
"Higher Order Lambda"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "HigherOrderLambda.juvix")
|
2023-01-16 17:13:17 +03:00
|
|
|
$(mkRelFile "out/HigherOrderLambda.out"),
|
|
|
|
PosTest
|
|
|
|
"Type Aliases"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Church.juvix")
|
2023-01-31 17:32:50 +03:00
|
|
|
$(mkRelFile "out/Church.out"),
|
|
|
|
PosTest
|
|
|
|
"Nested as patterns"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "AsPatterns.juvix")
|
2023-02-06 16:53:35 +03:00
|
|
|
$(mkRelFile "out/AsPatterns.out"),
|
|
|
|
PosTest
|
|
|
|
"Case expression"
|
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Case.juvix")
|
|
|
|
$(mkRelFile "out/Case.out")
|
2022-11-07 16:47:56 +03:00
|
|
|
]
|