2022-06-28 11:25:43 +03:00
|
|
|
module BackendC.Examples where
|
|
|
|
|
|
|
|
import BackendC.Base
|
|
|
|
import Base
|
|
|
|
import Data.FileEmbed
|
|
|
|
|
|
|
|
data ExampleTest = ExampleTest
|
|
|
|
{ _name :: String,
|
|
|
|
_relDir :: FilePath,
|
|
|
|
_mainFile :: FilePath,
|
|
|
|
_expectedDir :: FilePath,
|
2022-07-07 16:35:56 +03:00
|
|
|
_stdinText :: Text,
|
|
|
|
_stdlibMode :: StdlibMode
|
2022-06-28 11:25:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
makeLenses ''ExampleTest
|
|
|
|
|
|
|
|
exampleRoot :: FilePath
|
|
|
|
exampleRoot = "examples/milestone"
|
|
|
|
|
|
|
|
testDescr :: ExampleTest -> TestDescr
|
|
|
|
testDescr ExampleTest {..} =
|
|
|
|
let mainRoot = exampleRoot </> _relDir
|
|
|
|
expectedFile = $(makeRelativeToProject "tests/examplesExpected" >>= strToExp) </> _expectedDir </> "expected.golden"
|
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = mainRoot,
|
2022-07-07 16:35:56 +03:00
|
|
|
_testAssertion = Steps $ clangAssertion _stdlibMode _mainFile expectedFile _stdinText
|
2022-06-28 11:25:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
allTests :: TestTree
|
|
|
|
allTests =
|
|
|
|
testGroup
|
|
|
|
"Backend C milestone example tests"
|
|
|
|
(map (mkTest . testDescr) tests)
|
|
|
|
|
|
|
|
tests :: [ExampleTest]
|
|
|
|
tests =
|
2022-07-27 11:24:25 +03:00
|
|
|
[ ExampleTest "Validity Predicate example" "ValidityPredicates" "Tests.juvix" "ValidityPredicates" "" StdlibInclude,
|
2022-07-14 19:03:44 +03:00
|
|
|
ExampleTest "MiniTicTacToe example" "MiniTicTacToe" "MiniTicTacToe.juvix" "MiniTicTacToe" "aaa\n0\n10\n1\n2\n3\n3\n4\n5\n6\n7\n8\n9\n" StdlibInclude,
|
2022-07-15 13:17:22 +03:00
|
|
|
ExampleTest "Fibonacci example" "Fibonacci" "Fibonacci.juvix" "Fibonacci" "" StdlibInclude,
|
|
|
|
ExampleTest "Collatz sequence generator" "Collatz" "Collatz.juvix" "Collatz" "123\n" StdlibInclude
|
2022-06-28 11:25:43 +03:00
|
|
|
]
|