Exemplo n.º 1
0
        public void PeekCharStartTest()
        {
            var p = new ParserMoc();

            //var x = p.Parse().ToList();
            //Assert.AreEqual(new Expressions<Token> {Token.VarDecl, Token.entry}, x);
            using (var i = p.Parse().GetEnumerator()) {
                Assert.AreEqual(expected: 0, actual: p.State);

                Assert.IsTrue(i.MoveNext());
                Assert.AreEqual(expected: 1, actual: p.State);
                Assert.AreEqual(Token.VarDecl, i.Current);

                Assert.IsTrue(i.MoveNext());
                Assert.AreEqual(expected: 2, actual: p.State);
                Assert.AreEqual(Token.Identifier, i.Current);

                Assert.IsTrue(i.MoveNext());
                Assert.AreEqual(expected: 3, actual: p.State);
                Assert.AreEqual(Token.Call, i.Current);

                Assert.IsFalse(i.MoveNext());
                Assert.AreEqual(expected: 4, actual: p.State);
            }
        }
Exemplo n.º 2
0
        public void TestParserMoc()
        {
            var p = new ParserMoc();

            Assert.AreEqual(new List <Token> {
                Token.VarDecl, Token.Identifier, Token.Call
            }, p.ToList());
        }