Exemplo n.º 1
0
 public void ShouldBeAbleToRetrieveTokenNames()
 {
     var testLexer = new FooBarBazLexer("foo bar baz - quux");
     Assert.AreEqual("foo", testLexer.NameOfTokenType(1));
     Assert.AreEqual("id", testLexer.NameOfTokenType(5));
     Assert.AreEqual("whitespace", testLexer.NameOfTokenType(-1));
 }
Exemplo n.º 2
0
        public void ShouldBeAbleToRetrieveTokenNames()
        {
            var testLexer = new FooBarBazLexer("foo bar baz - quux");

            Assert.AreEqual("foo", testLexer.NameOfTokenType(1));
            Assert.AreEqual("id", testLexer.NameOfTokenType(5));
            Assert.AreEqual("whitespace", testLexer.NameOfTokenType(-1));
        }
Exemplo n.º 3
0
 public void ShouldLexTokens()
 {
     var testLexer = new FooBarBazLexer("foo bar baz - quux $corge");
     var tokens = testLexer.Tokens().ToList();
     var expected = @"foo type=foo:1, l.1 ch.1
     bar type=bar:2, l.1 ch.5
     baz type=baz:3, l.1 ch.9
     - type=-:6, l.1 ch.13
     quux type=quux:4, l.1 ch.15
     $corge type=id:5, l.1 ch.20";
     var actual = string.Join("\r\n", tokens.ConvertAll(t => string.Format("{0} type={1}:{2}, l.{3} ch.{4}", t.Content, testLexer.NameOfTokenType(t.TokenType), t.TokenType, t.Line, t.Character)));
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 4
0
        public void ShouldLexTokens()
        {
            var testLexer = new FooBarBazLexer("foo bar baz - quux $corge");
            var tokens    = testLexer.Tokens().ToList();
            var expected  = @"foo type=foo:1, l.1 ch.1
bar type=bar:2, l.1 ch.5
baz type=baz:3, l.1 ch.9
- type=-:6, l.1 ch.13
quux type=quux:4, l.1 ch.15
$corge type=id:5, l.1 ch.20";
            var actual    = string.Join("\r\n", tokens.ConvertAll(t => string.Format("{0} type={1}:{2}, l.{3} ch.{4}", t.Content, testLexer.NameOfTokenType(t.TokenType), t.TokenType, t.Line, t.Character)));

            Assert.AreEqual(expected, actual);
        }