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

243 lines
6.3 KiB
Haskell
Raw Normal View History

module Compilation.Positive where
import Base
import Compilation.Base
data PosTest = PosTest
{ _name :: String,
2023-01-17 11:41:07 +03:00
_dir :: Path Abs Dir,
_file :: Path Abs File,
_expectedFile :: Path Abs File
}
2023-01-17 11:41:07 +03:00
makeLenses ''PosTest
fromTest :: PosTest -> TestTree
fromTest = mkTest . toTestDescr
root :: Path Abs Dir
root = relToProject $(mkRelDir "tests/Compilation/positive/")
toTestDescr :: PosTest -> TestDescr
toTestDescr PosTest {..} =
2023-01-17 11:41:07 +03:00
let tRoot = _dir
file' = _file
expected' = _expectedFile
in TestDescr
{ _testName = _name,
_testRoot = tRoot,
_testAssertion = Steps $ compileAssertion file' expected'
}
filterOutTests :: [String] -> [PosTest] -> [PosTest]
filterOutTests out = filter (\PosTest {..} -> _name `notElem` out)
allTests :: TestTree
allTests =
testGroup
"Juvix compilation pipeline positive tests"
( map
(mkTest . toTestDescr)
( filterOutTests
[ "Merge sort"
]
tests
)
)
2023-01-17 11:41:07 +03:00
posTest :: String -> Path Rel Dir -> Path Rel File -> Path Rel File -> PosTest
posTest _name rdir rfile routfile =
let _dir = root <//> rdir
_file = _dir <//> rfile
_expectedFile = root <//> routfile
in PosTest {..}
tests :: [PosTest]
tests =
2023-01-17 11:41:07 +03:00
[ posTest
"Arithmetic operators"
$(mkRelDir ".")
$(mkRelFile "test001.juvix")
$(mkRelFile "out/test001.out"),
2023-01-17 11:41:07 +03:00
posTest
"Arithmetic operators inside lambdas"
$(mkRelDir ".")
$(mkRelFile "test002.juvix")
$(mkRelFile "out/test002.out"),
2023-01-19 12:47:12 +03:00
posTest
"Integer arithmetic"
$(mkRelDir ".")
$(mkRelFile "test003.juvix")
$(mkRelFile "out/test003.out"),
2023-01-17 11:41:07 +03:00
posTest
"IO builtins"
$(mkRelDir ".")
$(mkRelFile "test004.juvix")
$(mkRelFile "out/test004.out"),
2023-01-17 11:41:07 +03:00
posTest
"Higher-order functions"
$(mkRelDir ".")
$(mkRelFile "test005.juvix")
$(mkRelFile "out/test005.out"),
2023-01-17 11:41:07 +03:00
posTest
"If-then-else"
$(mkRelDir ".")
$(mkRelFile "test006.juvix")
$(mkRelFile "out/test006.out"),
2023-01-17 11:41:07 +03:00
posTest
"Pattern matching and lambda-case"
$(mkRelDir ".")
$(mkRelFile "test007.juvix")
$(mkRelFile "out/test007.out"),
2023-01-17 11:41:07 +03:00
posTest
"Recursion"
$(mkRelDir ".")
$(mkRelFile "test008.juvix")
$(mkRelFile "out/test008.out"),
2023-01-17 11:41:07 +03:00
posTest
"Tail recursion"
$(mkRelDir ".")
$(mkRelFile "test009.juvix")
$(mkRelFile "out/test009.out"),
2023-01-17 11:41:07 +03:00
posTest
"Let"
$(mkRelDir ".")
$(mkRelFile "test010.juvix")
$(mkRelFile "out/test010.out"),
2023-01-17 11:41:07 +03:00
posTest
"Tail recursion: Fibonacci numbers in linear time"
$(mkRelDir ".")
$(mkRelFile "test011.juvix")
$(mkRelFile "out/test011.out"),
2023-01-17 11:41:07 +03:00
posTest
"Trees"
$(mkRelDir ".")
$(mkRelFile "test012.juvix")
$(mkRelFile "out/test012.out"),
2023-01-17 11:41:07 +03:00
posTest
"Functions returning functions with variable capture"
$(mkRelDir ".")
$(mkRelFile "test013.juvix")
$(mkRelFile "out/test013.out"),
2023-01-17 11:41:07 +03:00
posTest
"Arithmetic"
$(mkRelDir ".")
$(mkRelFile "test014.juvix")
$(mkRelFile "out/test014.out"),
2023-01-17 11:41:07 +03:00
posTest
"Local functions with free variables"
$(mkRelDir ".")
$(mkRelFile "test015.juvix")
$(mkRelFile "out/test015.out"),
2023-01-17 11:41:07 +03:00
posTest
"Recursion through higher-order functions"
$(mkRelDir ".")
$(mkRelFile "test016.juvix")
$(mkRelFile "out/test016.out"),
2023-01-17 11:41:07 +03:00
posTest
"Tail recursion through higher-order functions"
$(mkRelDir ".")
$(mkRelFile "test017.juvix")
$(mkRelFile "out/test017.out"),
2023-01-17 11:41:07 +03:00
posTest
"Higher-order functions and recursion"
$(mkRelDir ".")
$(mkRelFile "test018.juvix")
$(mkRelFile "out/test018.out"),
2023-01-17 11:41:07 +03:00
posTest
"Self-application"
$(mkRelDir ".")
$(mkRelFile "test019.juvix")
$(mkRelFile "out/test019.out"),
2023-01-17 11:41:07 +03:00
posTest
"Recursive functions: McCarthy's 91 function, subtraction by increments"
$(mkRelDir ".")
$(mkRelFile "test020.juvix")
$(mkRelFile "out/test020.out"),
2023-01-17 11:41:07 +03:00
posTest
"Fast exponentiation"
$(mkRelDir ".")
$(mkRelFile "test021.juvix")
$(mkRelFile "out/test021.out"),
2023-01-17 11:41:07 +03:00
posTest
"Lists"
$(mkRelDir ".")
$(mkRelFile "test022.juvix")
$(mkRelFile "out/test022.out"),
2023-01-17 11:41:07 +03:00
posTest
"Mutual recursion"
$(mkRelDir ".")
$(mkRelFile "test023.juvix")
$(mkRelFile "out/test023.out"),
2023-01-17 11:41:07 +03:00
posTest
"Nested binders with variable capture"
$(mkRelDir ".")
$(mkRelFile "test024.juvix")
$(mkRelFile "out/test024.out"),
2023-01-17 11:41:07 +03:00
posTest
"Euclid's algorithm"
$(mkRelDir ".")
$(mkRelFile "test025.juvix")
$(mkRelFile "out/test025.out"),
2023-01-17 11:41:07 +03:00
posTest
"Functional queues"
$(mkRelDir ".")
$(mkRelFile "test026.juvix")
$(mkRelFile "out/test026.out"),
2023-01-17 11:41:07 +03:00
posTest
"Church numerals"
$(mkRelDir ".")
$(mkRelFile "test027.juvix")
$(mkRelFile "out/test027.out"),
2023-01-17 11:41:07 +03:00
posTest
"Streams without memoization"
$(mkRelDir ".")
$(mkRelFile "test028.juvix")
$(mkRelFile "out/test028.out"),
2023-01-17 11:41:07 +03:00
posTest
"Ackermann function"
$(mkRelDir ".")
$(mkRelFile "test029.juvix")
$(mkRelFile "out/test029.out"),
2023-01-17 11:41:07 +03:00
posTest
"Ackermann function (higher-order definition)"
$(mkRelDir ".")
$(mkRelFile "test030.juvix")
$(mkRelFile "out/test030.out"),
2023-01-17 11:41:07 +03:00
posTest
"Nested lists"
$(mkRelDir ".")
$(mkRelFile "test031.juvix")
$(mkRelFile "out/test031.out"),
2023-01-17 11:41:07 +03:00
posTest
"Merge sort"
$(mkRelDir ".")
$(mkRelFile "test032.juvix")
$(mkRelFile "out/test032.out"),
2023-01-17 11:41:07 +03:00
posTest
"Eta-expansion of builtins and constructors"
$(mkRelDir ".")
$(mkRelFile "test033.juvix")
$(mkRelFile "out/test033.out"),
2023-01-17 11:41:07 +03:00
posTest
"Recursive let"
$(mkRelDir ".")
$(mkRelFile "test034.juvix")
$(mkRelFile "out/test034.out"),
2023-01-17 11:41:07 +03:00
posTest
"Pattern matching"
$(mkRelDir ".")
$(mkRelFile "test035.juvix")
$(mkRelFile "out/test035.out"),
2023-01-17 11:41:07 +03:00
posTest
"Eta-expansion"
$(mkRelDir ".")
$(mkRelFile "test036.juvix")
$(mkRelFile "out/test036.out"),
2023-01-17 11:41:07 +03:00
posTest
"Applications with lets and cases in function position"
$(mkRelDir ".")
$(mkRelFile "test037.juvix")
$(mkRelFile "out/test037.out")
]