Skip to content

Commit

Permalink
[ testsuite ] test case for #210 (parsing CoercCat)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Apr 29, 2019
1 parent 71c6d72 commit 43f23b3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions testing/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ main = htfMain $
-- Use : and [] for this list such that lines can be swapped swiftly
-- (avoids the usual problems when trying to switch the first line
-- with a later line).

-- ParameterizedTests.current : -- Uncomment for prioritized test case.
OutputParser.tests :
RegressionTests.all :
ParameterizedTests.all :
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
10 changes: 10 additions & 0 deletions testing/regression-tests/210_NumberedCatWithoutCoerce/good01.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Parse Successful!

[Abstract Syntax]

EId (Ident "foo")

[Linearized tree]

foo
8 changes: 8 additions & 0 deletions testing/regression-tests/210_NumberedCatWithoutCoerce/test.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Andreas, 2019-04-29, issue #210.
-- Numbered categories need to be included in AST
-- even without coercion pragma.

EId. Exp2 ::= Ident;
EPair. Exp1 ::= Exp2 "," Exp2;

-- Should generate a valid parser/printer for Exp2.
23 changes: 17 additions & 6 deletions testing/src/ParameterizedTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ allWithParams params = makeTestSuite (tpName params) $ concat $
]
]

-- | This parameterized test is called first.
-- Use it while working in connection with a certain test case. (For quicker response.)
current :: Test
current = makeTestSuite "Current parameterized test" $
map (`makeTestCase` ("regression-tests" </> cur)) parameters
where
cur = "210_NumberedCatWithoutCoerce"

-- | BNFC should not proceed if grammar does not define any rules.
noRulesTest :: TestParameters -> Test
noRulesTest params = do
Expand Down Expand Up @@ -114,22 +122,23 @@ exampleTests params =
forM_ examples $ \example ->
tpRunTestProg params (toTextArg lang) [filename example]

-- | To test certain grammatical constructions or interractions between rules,
-- | To test certain grammatical constructions or interactions between rules,
-- test grammar can be created under the regression-tests directory,
-- together with valid and invalid inputs.
testCases :: TestParameters -> [Test]
testCases params =
map makeTestCase
[ "regression-tests/204_InternalToken"
map (makeTestCase params)
[ "regression-tests/210_NumberedCatWithoutCoerce"
, "regression-tests/204_InternalToken"
, "regression-tests/249_unicode"
, "regression-tests/#100_coercion_lists"
, "regression-tests/#134_category_named_I"
, "regression-tests/comments"
, "regression-tests/#149"
]
where
mkTitle dir = encodeString (filename dir)
makeTestCase dir =

makeTestCase :: TestParameters -> FilePath -> Test
makeTestCase params dir =
makeShellyTest (mkTitle dir) $ withTmpDir $ \tmp -> do
dir <- absPath dir
cd tmp
Expand All @@ -150,6 +159,8 @@ testCases params =
forM_ bad $ \f -> do
errExit False $ tpRunTestProg params "test" [f]
lastExitCode >>= assertEqual 1
where
mkTitle dir = encodeString (filename dir)

-- | To test that @distclean@ removes all generated files.
distcleanTest :: TestParameters -> Test
Expand Down

0 comments on commit 43f23b3

Please sign in to comment.