2022-05-05 16:12:17 +03:00
|
|
|
module BackendC.Positive where
|
|
|
|
|
2022-06-28 11:25:43 +03:00
|
|
|
import BackendC.Base
|
2022-05-05 16:12:17 +03:00
|
|
|
import Base
|
|
|
|
|
|
|
|
data PosTest = PosTest
|
|
|
|
{ _name :: String,
|
2022-06-30 12:31:08 +03:00
|
|
|
_relDir :: FilePath,
|
2022-08-01 13:53:19 +03:00
|
|
|
_compileMode :: CompileMode
|
2022-05-05 16:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
makeLenses ''PosTest
|
|
|
|
|
|
|
|
root :: FilePath
|
|
|
|
root = "tests/positive/MiniC"
|
|
|
|
|
|
|
|
mainFile :: FilePath
|
2022-07-08 14:59:45 +03:00
|
|
|
mainFile = "Input.juvix"
|
2022-05-05 16:12:17 +03:00
|
|
|
|
2022-05-13 12:44:06 +03:00
|
|
|
expectedFile :: FilePath
|
|
|
|
expectedFile = "expected.golden"
|
|
|
|
|
2022-05-05 16:12:17 +03:00
|
|
|
testDescr :: PosTest -> TestDescr
|
|
|
|
testDescr PosTest {..} =
|
|
|
|
let tRoot = root </> _relDir
|
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = tRoot,
|
2022-08-01 13:53:19 +03:00
|
|
|
_testAssertion = Steps $ case _compileMode of
|
|
|
|
WASI stdlibMode -> wasiClangAssertion stdlibMode mainFile expectedFile ""
|
|
|
|
WASM i -> wasmClangAssertion i mainFile expectedFile
|
2022-05-05 16:12:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
allTests :: TestTree
|
|
|
|
allTests =
|
|
|
|
testGroup
|
|
|
|
"Backend C positive tests"
|
|
|
|
(map (mkTest . testDescr) tests)
|
|
|
|
|
|
|
|
tests :: [PosTest]
|
|
|
|
tests =
|
2022-08-01 13:53:19 +03:00
|
|
|
[ PosTest "HelloWorld" "HelloWorld" (WASI StdlibExclude),
|
|
|
|
PosTest "Inductive types and pattern matching" "Nat" (WASI StdlibExclude),
|
|
|
|
PosTest "Polymorphic types" "Polymorphism" (WASI StdlibExclude),
|
|
|
|
PosTest "Polymorphic axioms" "PolymorphicAxioms" (WASI StdlibExclude),
|
|
|
|
PosTest "Polymorphic target" "PolymorphicTarget" (WASI StdlibExclude),
|
|
|
|
PosTest "Multiple modules" "MultiModules" (WASI StdlibExclude),
|
|
|
|
PosTest "Higher Order Functions" "HigherOrder" (WASI StdlibExclude),
|
|
|
|
PosTest "Higher Order Functions and explicit holes" "PolymorphismHoles" (WASI StdlibExclude),
|
|
|
|
PosTest "Closures with no environment" "ClosureNoEnv" (WASI StdlibExclude),
|
|
|
|
PosTest "Closures with environment" "ClosureEnv" (WASI StdlibExclude),
|
|
|
|
PosTest "SimpleFungibleTokenImplicit" "SimpleFungibleTokenImplicit" (WASI StdlibExclude),
|
|
|
|
PosTest "Mutually recursive function" "MutuallyRecursive" (WASI StdlibExclude),
|
|
|
|
PosTest "Nested List type" "NestedList" (WASI StdlibExclude),
|
|
|
|
PosTest "Builtin types and functions" "Builtins" (WASI StdlibExclude),
|
|
|
|
PosTest "Import from embedded standard library" "StdlibImport" (WASI StdlibInclude),
|
|
|
|
PosTest "Axiom without a compile block" "AxiomNoCompile" (WASI StdlibInclude),
|
|
|
|
PosTest "Invoke a function using exported name" "ExportName" (WASM (WASMInfo "fun" [])),
|
|
|
|
PosTest "Invoke a function using exported name with args" "ExportNameArgs" (WASM (WASMInfo "fun" ["0"]))
|
2022-05-05 16:12:17 +03:00
|
|
|
]
|