2022-09-23 16:43:18 +03:00
|
|
|
module Typecheck.Positive where
|
2022-04-05 23:02:03 +03:00
|
|
|
|
|
|
|
import Base
|
2022-08-03 14:20:40 +03:00
|
|
|
import Juvix.Compiler.Pipeline
|
2022-09-23 16:43:18 +03:00
|
|
|
import Typecheck.Negative qualified as N
|
2022-04-05 23:02:03 +03:00
|
|
|
|
|
|
|
data PosTest = PosTest
|
2022-04-08 13:46:37 +03:00
|
|
|
{ _name :: String,
|
|
|
|
_relDir :: FilePath,
|
|
|
|
_file :: FilePath
|
2022-04-05 23:02:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
root :: FilePath
|
|
|
|
root = "tests/positive"
|
|
|
|
|
|
|
|
testDescr :: PosTest -> TestDescr
|
|
|
|
testDescr PosTest {..} =
|
2022-04-08 13:46:37 +03:00
|
|
|
let tRoot = root </> _relDir
|
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = tRoot,
|
|
|
|
_testAssertion = Single $ do
|
2022-05-30 14:40:52 +03:00
|
|
|
let entryPoint = defaultEntryPoint _file
|
2022-09-14 17:16:15 +03:00
|
|
|
(void . runIO' entryPoint) upToInternalTyped
|
2022-04-08 13:46:37 +03:00
|
|
|
}
|
2022-04-05 23:02:03 +03:00
|
|
|
|
2022-07-23 10:27:12 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- Testing --no-positivity flag with all related negative tests
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
rootNegTests :: FilePath
|
|
|
|
rootNegTests = "tests/negative/"
|
|
|
|
|
|
|
|
testNoPositivityFlag :: N.NegTest -> TestDescr
|
|
|
|
testNoPositivityFlag N.NegTest {..} =
|
|
|
|
let tRoot = rootNegTests </> _relDir
|
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = tRoot,
|
|
|
|
_testAssertion = Single $ do
|
|
|
|
let entryPoint =
|
2022-08-19 17:57:07 +03:00
|
|
|
(defaultEntryPoint _file)
|
|
|
|
{ _entryPointNoPositivity = True
|
2022-07-23 10:27:12 +03:00
|
|
|
}
|
|
|
|
|
2022-09-14 17:16:15 +03:00
|
|
|
(void . runIO' entryPoint) upToInternal
|
2022-07-23 10:27:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
negPositivityTests :: [N.NegTest]
|
|
|
|
negPositivityTests = N.negPositivityTests
|
|
|
|
|
|
|
|
testPositivityKeyword :: [PosTest]
|
|
|
|
testPositivityKeyword =
|
|
|
|
[ PosTest
|
|
|
|
"Mark T0 data type as strictly positive"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal/Positivity"
|
2022-07-23 10:27:12 +03:00
|
|
|
"E5.juvix"
|
|
|
|
]
|
|
|
|
|
|
|
|
positivityTestGroup :: TestTree
|
|
|
|
positivityTestGroup =
|
|
|
|
testGroup
|
|
|
|
"Positive tests for the positivity condition"
|
|
|
|
[ testGroup
|
|
|
|
"Bypass positivity checking using --non-positivity flag on negative tests"
|
|
|
|
(map (mkTest . testNoPositivityFlag) negPositivityTests),
|
|
|
|
testGroup
|
|
|
|
"Usages of the positive keyword"
|
|
|
|
(map (mkTest . testDescr) testPositivityKeyword)
|
|
|
|
]
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2022-04-05 23:02:03 +03:00
|
|
|
allTests :: TestTree
|
|
|
|
allTests =
|
|
|
|
testGroup
|
2022-07-23 10:27:12 +03:00
|
|
|
"Typecheck positive tests"
|
|
|
|
[ testGroup
|
|
|
|
"General typechecking tests"
|
|
|
|
(map (mkTest . testDescr) tests),
|
|
|
|
positivityTestGroup
|
|
|
|
]
|
2022-04-05 23:02:03 +03:00
|
|
|
|
|
|
|
tests :: [PosTest]
|
|
|
|
tests =
|
|
|
|
[ PosTest
|
|
|
|
"Simple"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"Simple.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
|
|
|
"Literal String matches any type"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"LiteralString.juvix",
|
2022-07-04 19:15:35 +03:00
|
|
|
PosTest
|
|
|
|
"Box type"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"Box.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
|
|
|
"Literal Int matches any type"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"LiteralInt.juvix",
|
2022-06-01 18:54:53 +03:00
|
|
|
PosTest
|
2022-06-13 15:25:22 +03:00
|
|
|
"PolySimpleFungibleToken"
|
2022-06-01 18:54:53 +03:00
|
|
|
"FullExamples"
|
2022-07-08 14:59:45 +03:00
|
|
|
"SimpleFungibleTokenImplicit.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
2022-05-06 13:45:09 +03:00
|
|
|
"GHC backend MonoSimpleFungibleToken"
|
|
|
|
"FullExamples"
|
2022-07-08 14:59:45 +03:00
|
|
|
"MonoSimpleFungibleToken.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
|
|
|
"Axiom"
|
|
|
|
"."
|
2022-07-08 14:59:45 +03:00
|
|
|
"Axiom.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
|
|
|
"Inductive"
|
|
|
|
"."
|
2022-07-08 14:59:45 +03:00
|
|
|
"Inductive.juvix",
|
2022-04-05 23:02:03 +03:00
|
|
|
PosTest
|
|
|
|
"Operators"
|
|
|
|
"."
|
2022-07-08 14:59:45 +03:00
|
|
|
"Operators.juvix",
|
2022-06-02 14:02:07 +03:00
|
|
|
PosTest
|
|
|
|
"Holes in type signature"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"HoleInSignature.juvix",
|
2022-04-22 11:06:34 +03:00
|
|
|
PosTest
|
|
|
|
"Polymorphism and higher rank functions"
|
|
|
|
"."
|
2022-07-08 14:59:45 +03:00
|
|
|
"Polymorphism.juvix",
|
2022-06-01 18:54:53 +03:00
|
|
|
PosTest
|
|
|
|
"Polymorphism and higher rank functions with explicit holes"
|
|
|
|
"."
|
2022-07-08 14:59:45 +03:00
|
|
|
"PolymorphismHoles.juvix",
|
2022-06-13 19:16:32 +03:00
|
|
|
PosTest
|
|
|
|
"Implicit arguments"
|
2022-08-03 14:20:40 +03:00
|
|
|
"Internal"
|
2022-07-08 14:59:45 +03:00
|
|
|
"Implicit.juvix",
|
2022-07-25 13:30:18 +03:00
|
|
|
PosTest
|
|
|
|
"Simple type alias"
|
|
|
|
"."
|
|
|
|
"TypeAlias.juvix",
|
2022-07-15 19:39:11 +03:00
|
|
|
PosTest
|
|
|
|
"Refine hole in type signature"
|
|
|
|
"272"
|
|
|
|
"M.juvix",
|
2022-07-15 18:57:04 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern match a hole type"
|
|
|
|
"265"
|
|
|
|
"M.juvix",
|
2022-08-21 13:16:26 +03:00
|
|
|
PosTest
|
|
|
|
"Pattern match type synonym"
|
|
|
|
"issue1466"
|
|
|
|
"M.juvix",
|
2022-07-01 17:59:52 +03:00
|
|
|
PosTest
|
|
|
|
"Import a builtin multiple times"
|
|
|
|
"BuiltinsMultiImport"
|
2022-07-08 14:59:45 +03:00
|
|
|
"Input.juvix",
|
2022-09-23 16:43:18 +03:00
|
|
|
PosTest
|
|
|
|
"Basic lambda functions"
|
|
|
|
"Internal"
|
|
|
|
"Lambda.juvix",
|
2022-09-26 20:14:17 +03:00
|
|
|
PosTest
|
|
|
|
"Simple mutual inference"
|
|
|
|
"Internal"
|
|
|
|
"Mutual.juvix",
|
2022-07-03 18:16:46 +03:00
|
|
|
PosTest
|
|
|
|
"open import a builtin multiple times"
|
|
|
|
"BuiltinsMultiOpenImport"
|
2022-10-27 13:17:03 +03:00
|
|
|
"Input.juvix",
|
|
|
|
PosTest
|
|
|
|
"As Patterns"
|
|
|
|
"Internal"
|
|
|
|
"AsPattern.juvix"
|
2022-04-05 23:02:03 +03:00
|
|
|
]
|