CFGLibTest.Unit.TestCFGToCNF.TestAccepts01 C# (CSharp) Method

TestAccepts01() private method

private TestAccepts01 ( ) : void
return void
		public void TestAccepts01() {
			var productions = new HashSet<Production> {
				CFGParser.Production("<S> -> 'x2' <A> <A>"),
				CFGParser.Production("<S> -> ε"),
				CFGParser.Production("<A> -> 'x4' <S> 'x2'"),
				CFGParser.Production("<A> -> ε"),
			};
			Grammar g = new Grammar(productions, Nonterminal.Of("S"));
			CNFGrammar h = g.ToCNF();

			Assert.IsTrue(h.Accepts(Sentence.FromLetters("")));
			Assert.IsTrue(h.Accepts(Sentence.FromWords("x2")));
			Assert.IsTrue(h.Accepts(Sentence.FromWords("x2 x4 x2")));
			Assert.IsTrue(h.Accepts(Sentence.FromWords("x2 x4 x2 x4 x2")));
		}