Browse Source

Finished the Lexer position test, please add some more VB test if you know the language better than me :)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@305 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Andrea Paatz 21 years ago
parent
commit
5872552ae9
  1. 4
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs
  2. 99
      src/Libraries/NRefactory/Test/Lexer/VBNet/LexerPositionTests.cs

4
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -156,7 +156,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
ReadComment();
if (!lineEnd) {
lineEnd = true;
return new Token(Tokens.EOL, x, y, "\n");
return new Token(Tokens.EOL, Col, Line, "\n");
}
continue;
}
@ -375,7 +375,7 @@ namespace ICSharpCode.NRefactory.Parser.VB @@ -375,7 +375,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
digit += (char)ReaderRead();
}
} else {
nextToken = new Token(Tokens.Dot, x, y);
nextToken = new Token(Tokens.Dot, Col - 1, Line);
}
}

99
src/Libraries/NRefactory/Test/Lexer/VBNet/LexerPositionTests.cs

@ -38,14 +38,15 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -38,14 +38,15 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
t = l.NextToken();
Assert.AreEqual(new Point(8, 1), t.Location);
}
// [Test]
// public void TestReturn()
// {
// ILexer l = GenerateLexer("public\nstatic");
// Token t = l.NextToken();
// t = l.NextToken();
// Assert.AreEqual(new Point(1, 2), t.Location);
// }
[Test]
public void TestReturn()
{
ILexer l = GenerateLexer("public\nstatic");
Token t = l.NextToken();
t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
}
[Test]
public void TestSpace()
{
@ -60,59 +61,35 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB @@ -60,59 +61,35 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
}
// [Test]
// public void TestHexNumber()
// {
// ILexer l = GenerateLexer("0x142 public");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(7, 1), t.Location);
// }
// [Test]
// public void TestHexNumberChar()
// {
// ILexer l = GenerateLexer("\'\\x224\' public");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(9, 1), t.Location);
// }
// [Test]
// public void TestFloationPointNumber()
// {
// ILexer l = GenerateLexer("0.142 public");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(7, 1), t.Location);
// }
// [Test]
// public void TestVerbatimString()
// {
// ILexer l = GenerateLexer("@\"a\"\"a\" public");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(9, 1), t.Location);
// }
// [Test]
// public void TestNoFloationPointNumber()
// {
// ILexer l = GenerateLexer("0.a");
// Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken();
// Assert.AreEqual(new Point(3, 1), t.Location);
// }
// [Test]
// public void TestNumber()
// {
// ILexer l = GenerateLexer("142\nstatic");
// Token t = l.NextToken();
// t = l.NextToken();
// Assert.AreEqual(new Point(1, 2), t.Location);
// }
[Test]
public void TestFloationPointNumber()
{
ILexer l = GenerateLexer("0.142 public");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(7, 1), t.Location);
}
[Test]
public void TestNoFloationPointNumber()
{
ILexer l = GenerateLexer("5.a");
Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(2, 1), t.Location);
t = l.NextToken();
Assert.AreEqual(new Point(3, 1), t.Location);
}
[Test]
public void TestNumber()
{
ILexer l = GenerateLexer("142\nstatic");
Token t = l.NextToken();
t = l.NextToken();
t = l.NextToken();
Assert.AreEqual(new Point(1, 2), t.Location);
}
[Test]
public void TestNumber2()
{

Loading…
Cancel
Save