1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/test/Scope/Negative.hs
Jonathan Cubides de6fabf625
v0.1.1 (#15)
* add references to the syntax and cleanup code

* [make] add .PHONY to Makefile targets

* [parser] add parser / pretty for axiom backends

* Pairing progress

* [scoper] Add support for Axiom backends

* [parser] Fix foreign block parsing

* [ app ] adds --no-colors flag for the scope command

* [ghc] upgrade to ghc 9.2.2

* use GHC2021

* [doc] Remove out-of-date comment

* [test] Add ambiguity tests

* [scoper] Improve resolution of local symbols

* [error] WIP improving ambiguity error messages

* [ clean-up ] new lab folder for experimentation

* [ app ] ixes the lint warning

* [ Termination ] removes Alga dependency

* [error] Add message for ambiguous symbol error

* [error] Add ambiguous module message

* [scoper] Remove ErrGeneric

* [test] Add test to suite

* [test] show diff when ast's are different

* [ lab ] folder organization

* [ Makefile ] add targets with --watch option (stack cmds) and remove unused things

* [ app ] add --version flag and fixed warnings and formatting

* [test] remove fromRightIO to fix ambiguity error

* [test] Add test of shadowing public open

* [scoper] Add visibility annotation for Name

* prepare buildIntoTable

* [ Concrete ] add instance of hashable for refs.

* add InfoTableBuilder effect

* [ scoper ] add InfoTableBuilder effect

* [ CHANGELOG ] updated v0.1.1

* [ README ] org version now

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2022-03-25 18:16:34 +01:00

125 lines
3.3 KiB
Haskell

module Scope.Negative (allTests) where
import Base
import MiniJuvix.Syntax.Concrete.Scoped.Error
import qualified MiniJuvix.Syntax.Concrete.Scoped.Scoper as M
type FailMsg = String
data NegTest = NegTest {
name :: String,
relDir :: FilePath,
file :: FilePath,
checkErr :: ScopeError -> Maybe FailMsg
}
testDescr :: NegTest -> TestDescr
testDescr NegTest {..} = TestDescr {
testName = name,
testRoot = root </> relDir,
testAssertion = Single $ do
p <- parseModuleIO file >>= M.scopeCheck1IO "."
case p of
Left err -> whenJust (checkErr err) assertFailure
Right _ -> assertFailure "The scope checker did not find an error."
}
allTests :: TestTree
allTests = testGroup "Scope negative tests"
(map (mkTest . testDescr) tests)
root :: FilePath
root = "tests/negative"
wrongError :: Maybe FailMsg
wrongError = Just "Incorrect error"
tests :: [NegTest]
tests = [
NegTest "Not in scope" "."
"NotInScope.mjuvix" $ \case
ErrSymNotInScope{} -> Nothing
_ -> wrongError
, NegTest "Multiple declarations" "."
"MultipleDeclarations.mjuvix" $ \case
ErrMultipleDeclarations{} -> Nothing
_ -> wrongError
, NegTest "Import cycle" "ImportCycle"
"A.mjuvix" $ \case
ErrImportCycle {} -> Nothing
_ -> wrongError
, NegTest "Binding group conflict (function clause)"
"BindGroupConflict"
"Clause.mjuvix" $ \case
ErrBindGroup {} -> Nothing
_ -> wrongError
, NegTest "Binding group conflict (lambda clause)"
"BindGroupConflict"
"Lambda.mjuvix" $ \case
ErrBindGroup {} -> Nothing
_ -> wrongError
, NegTest "Infix error (expression)"
"."
"InfixError.mjuvix" $ \case
ErrInfixParser {} -> Nothing
_ -> wrongError
, NegTest "Infix error (pattern)"
"."
"InfixErrorP.mjuvix" $ \case
ErrInfixPattern {} -> Nothing
_ -> wrongError
, NegTest "Duplicate fixity declaration"
"."
"DuplicateFixity.mjuvix" $ \case
ErrDuplicateFixity {} -> Nothing
_ -> wrongError
, NegTest "Multiple export conflict"
"."
"MultipleExportConflict.mjuvix" $ \case
ErrMultipleExport {} -> Nothing
_ -> wrongError
, NegTest "Module not in scope"
"."
"ModuleNotInScope.mjuvix" $ \case
ErrModuleNotInScope {} -> Nothing
_ -> wrongError
, NegTest "Unused operator syntax definition"
"."
"UnusedOperatorDef.mjuvix" $ \case
ErrUnusedOperatorDef {} -> Nothing
_ -> wrongError
, NegTest "Ambiguous symbol"
"."
"AmbiguousSymbol.mjuvix" $ \case
ErrAmbiguousSym {} -> Nothing
_ -> wrongError
, NegTest "Lacks function clause"
"."
"LacksFunctionClause.mjuvix" $ \case
ErrLacksFunctionClause {} -> Nothing
_ -> wrongError
, NegTest "Incorrect top module path"
"."
"WrongModuleName.mjuvix" $ \case
ErrWrongTopModuleName {} -> Nothing
_ -> wrongError
, NegTest "Ambiguous export"
"."
"AmbiguousExport.mjuvix" $ \case
ErrMultipleExport {} -> Nothing
_ -> wrongError
, NegTest "Ambiguous nested modules"
"."
"AmbiguousModule.mjuvix" $ \case
ErrAmbiguousModuleSym {} -> Nothing
_ -> wrongError
, NegTest "Ambiguous nested constructors"
"."
"AmbiguousConstructor.mjuvix" $ \case
ErrAmbiguousSym {} -> Nothing
_ -> wrongError
]