1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 17:32:00 +03:00
juvix/test/Core/Eval/Positive.hs

274 lines
7.2 KiB
Haskell
Raw Normal View History

module Core.Eval.Positive where
import Base
import Core.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/Core/positive")
testDescr :: PosTest -> TestDescr
testDescr PosTest {..} =
2022-12-20 15:05:40 +03:00
let tRoot = root <//> _relDir
file' = tRoot <//> _file
expected' = tRoot <//> _expectedFile
in TestDescr
{ _testName = _name,
_testRoot = tRoot,
2022-12-20 15:05:40 +03:00
_testAssertion = Steps $ coreEvalAssertion file' expected' [] (const (return ()))
}
filterOutTests :: [String] -> [PosTest] -> [PosTest]
filterOutTests out = filter (\PosTest {..} -> _name `notElem` out)
allTests :: TestTree
allTests =
testGroup
"JuvixCore positive tests"
(map (mkTest . testDescr) tests)
tests :: [PosTest]
tests =
[ PosTest
"Arithmetic operators"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test001.jvc")
$(mkRelFile "out/test001.out"),
PosTest
"Arithmetic operators inside lambdas"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test002.jvc")
$(mkRelFile "out/test002.out"),
PosTest
"Empty program with comments"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test003.jvc")
$(mkRelFile "out/test003.out"),
PosTest
"IO builtins"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test004.jvc")
$(mkRelFile "out/test004.out"),
PosTest
"Higher-order functions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test005.jvc")
$(mkRelFile "out/test005.out"),
PosTest
"If-then-else"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test006.jvc")
$(mkRelFile "out/test006.out"),
PosTest
"Case"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test007.jvc")
$(mkRelFile "out/test007.out"),
PosTest
"Recursion"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test008.jvc")
$(mkRelFile "out/test008.out"),
PosTest
"Tail recursion"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test009.jvc")
$(mkRelFile "out/test009.out"),
PosTest
"Let"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test010.jvc")
$(mkRelFile "out/test010.out"),
PosTest
"Tail recursion: Fibonacci numbers in linear time"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test011.jvc")
$(mkRelFile "out/test011.out"),
PosTest
"Trees"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test012.jvc")
$(mkRelFile "out/test012.out"),
PosTest
"Functions returning functions with variable capture"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test013.jvc")
$(mkRelFile "out/test013.out"),
PosTest
"Arithmetic"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test014.jvc")
$(mkRelFile "out/test014.out"),
PosTest
"Local functions with free variables"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test015.jvc")
$(mkRelFile "out/test015.out"),
PosTest
"Recursion through higher-order functions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test016.jvc")
$(mkRelFile "out/test016.out"),
PosTest
"Tail recursion through higher-order functions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test017.jvc")
$(mkRelFile "out/test017.out"),
PosTest
"Higher-order functions and recursion"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test018.jvc")
$(mkRelFile "out/test018.out"),
PosTest
"Self-application"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test019.jvc")
$(mkRelFile "out/test019.out"),
PosTest
"Recursive functions: McCarthy's 91 function, subtraction by increments"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test020.jvc")
$(mkRelFile "out/test020.out"),
PosTest
"Higher-order recursive functions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test021.jvc")
$(mkRelFile "out/test021.out"),
PosTest
"Fast exponentiation"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test022.jvc")
$(mkRelFile "out/test022.out"),
PosTest
"Lists"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test023.jvc")
$(mkRelFile "out/test023.out"),
PosTest
"Structural equality"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test024.jvc")
$(mkRelFile "out/test024.out"),
PosTest
"Mutual recursion"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test025.jvc")
$(mkRelFile "out/test025.out"),
PosTest
"Nested 'case', 'let' and 'if' with variable capture"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test026.jvc")
$(mkRelFile "out/test026.out"),
PosTest
"Euclid's algorithm"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test027.jvc")
$(mkRelFile "out/test027.out"),
PosTest
"Functional queues"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test028.jvc")
$(mkRelFile "out/test028.out"),
PosTest
"Church numerals"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test029.jvc")
$(mkRelFile "out/test029.out"),
PosTest
"Streams without memoization"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test030.jvc")
$(mkRelFile "out/test030.out"),
PosTest
"Ackermann function"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test031.jvc")
$(mkRelFile "out/test031.out"),
PosTest
"Ackermann function (higher-order definition)"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test032.jvc")
$(mkRelFile "out/test032.out"),
PosTest
"Nested lists"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test033.jvc")
$(mkRelFile "out/test033.out"),
{- PosTest
"Evaluation order"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test034.jvc")
$(mkRelFile "out/test034.out"), -}
PosTest
"Merge sort"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test035.jvc")
$(mkRelFile "out/test035.out"),
PosTest
"Big numbers"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test036.jvc")
$(mkRelFile "out/test036.out"),
PosTest
"Global variables"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test037.jvc")
$(mkRelFile "out/test037.out"),
PosTest
"Global variables and forward declarations"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test038.jvc")
$(mkRelFile "out/test038.out"),
PosTest
"Eta-expansion of builtins and constructors"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test039.jvc")
$(mkRelFile "out/test039.out"),
2022-09-06 13:28:09 +03:00
PosTest
"LetRec"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test040.jvc")
$(mkRelFile "out/test040.out"),
PosTest
"Match with complex patterns"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test041.jvc")
$(mkRelFile "out/test041.out"),
PosTest
"Type annotations"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test042.jvc")
$(mkRelFile "out/test042.out"),
PosTest
"Dependent lambda-abstractions"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test043.jvc")
$(mkRelFile "out/test043.out"),
PosTest
"Eta-expansion"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test044.jvc")
$(mkRelFile "out/test044.out"),
PosTest
"Type application and abstraction"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test045.jvc")
$(mkRelFile "out/test045.out"),
PosTest
"Applications with lets and cases in function position"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test046.jvc")
$(mkRelFile "out/test046.out"),
PosTest
"Builtin natural numbers"
2022-12-20 15:05:40 +03:00
$(mkRelDir ".")
$(mkRelFile "test047.jvc")
$(mkRelFile "out/test047.out")
]