mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 18:13:56 +03:00
6a45484e24
* Update SimpleFungibleToken to use stdlib We do not want to put an Int type into the standard library before we have builtin support for arbitrary precision integers. So we include the Int type locally in the project for now. * Update reference to stdlib * Fix shell-tests for SimpleFungibleToken
44 lines
1.4 KiB
Haskell
44 lines
1.4 KiB
Haskell
module BackendC.Examples where
|
|
|
|
import BackendC.Base
|
|
import Base
|
|
import Data.FileEmbed
|
|
|
|
data ExampleTest = ExampleTest
|
|
{ _name :: String,
|
|
_relDir :: FilePath,
|
|
_mainFile :: FilePath,
|
|
_expectedDir :: FilePath,
|
|
_stdinText :: Text,
|
|
_stdlibMode :: StdlibMode
|
|
}
|
|
|
|
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,
|
|
_testAssertion = Steps $ clangAssertion _stdlibMode _mainFile expectedFile _stdinText
|
|
}
|
|
|
|
allTests :: TestTree
|
|
allTests =
|
|
testGroup
|
|
"Backend C milestone example tests"
|
|
(map (mkTest . testDescr) tests)
|
|
|
|
tests :: [ExampleTest]
|
|
tests =
|
|
[ ExampleTest "Validity Predicate example" "ValidityPredicates" "Tests.juvix" "ValidityPredicates" "" StdlibInclude,
|
|
ExampleTest "MiniTicTacToe example" "MiniTicTacToe" "MiniTicTacToe.juvix" "MiniTicTacToe" "aaa\n0\n10\n1\n2\n3\n3\n4\n5\n6\n7\n8\n9\n" StdlibInclude,
|
|
ExampleTest "Fibonacci example" "Fibonacci" "Fibonacci.juvix" "Fibonacci" "" StdlibInclude,
|
|
ExampleTest "Collatz sequence generator" "Collatz" "Collatz.juvix" "Collatz" "123\n" StdlibInclude
|
|
]
|