Permalink
Browse files

Added another test grammer, re-grouped tests

  • Loading branch information...
1 parent 7eff2ea commit 131c7921ef8856a9c65280f250443b227f100c82 @adept committed Apr 27, 2010
Showing with 24 additions and 7 deletions.
  1. +24 −7 Tests.hs
View
@@ -12,14 +12,18 @@ import Grammar
main = defaultMain tests
tests = [
- testGroup "SAB grammar from ldta" [
- testCase "aad OK" (test_sab "aad" True),
- testCase "acd OK" (test_sab "acd" True),
- testCase "add Fails" (test_sab "add" False)
- ]
- , testGroup "G1 grammar from ldta" [
- testCase "a^20 b^150 a OK" test_g1
+ testGroup "Grammars from ldta" [
+ testCase "SAB: aad OK" (test_sab "aad" True),
+ testCase "SAB: acd OK" (test_sab "acd" True),
+ testCase "SAB: add Fails" (test_sab "add" False),
+ testCase "Г1: (a^20)(b^150)(a) OK" test_g1,
+ testCase "Г2*: (b^20) OK" (test_g2star 20),
+ testCase "Г2: (b^20) OK" (test_g2 20)
]
+ , testGroup "Grammar from GLR parsing in Haskell" [
+ testCase "(b^20) is OK" (test_glr 20),
+ testCase "(b^25) is OK" (test_glr 25)
+ ]
, testGroup "Another test grammar" gr_tests
, testGroup "Simple recurisve grammar" rec_tests
]
@@ -93,3 +97,16 @@ rec_tests = flip map testData $
testData =
[(replicate n 'a', True) | n <- [0..10]] ++
[(s,False) | s <- ["ab","ba","b","aab"]]
+
+-- From "Generalized LR parsing in Haskell"
+-- S : T {}
+-- T : A 'b' {} | T T T {}
+-- A : T 'b' A A A {} | T T 'b' {} | {}
+glr = [ ("S", [[Nonterminal "T"]]),
+ ("T", [[Nonterminal "A", Terminal 'b']
+ ,[Nonterminal "T", Nonterminal "T", Nonterminal "T"]]),
+ ("A", [[Nonterminal "T", Terminal 'b', Nonterminal "A", Nonterminal "A", Nonterminal "A"]
+ ,[Nonterminal "T", Nonterminal "T", Terminal 'b']
+ ,[]])
+ ]
+test_glr n = parse glr (replicate n 'b') @?= True

0 comments on commit 131c792

Please sign in to comment.