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
ReadComment(); ReadComment();
if (!lineEnd) { if (!lineEnd) {
lineEnd = true; lineEnd = true;
return new Token(Tokens.EOL, x, y, "\n"); return new Token(Tokens.EOL, Col, Line, "\n");
} }
continue; continue;
} }
@ -375,7 +375,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
digit += (char)ReaderRead(); digit += (char)ReaderRead();
} }
} else { } 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
t = l.NextToken(); t = l.NextToken();
Assert.AreEqual(new Point(8, 1), t.Location); Assert.AreEqual(new Point(8, 1), t.Location);
} }
// [Test] [Test]
// public void TestReturn() public void TestReturn()
// { {
// ILexer l = GenerateLexer("public\nstatic"); ILexer l = GenerateLexer("public\nstatic");
// Token t = l.NextToken(); Token t = l.NextToken();
// t = l.NextToken(); t = l.NextToken();
// Assert.AreEqual(new Point(1, 2), t.Location); t = l.NextToken();
// } Assert.AreEqual(new Point(1, 2), t.Location);
}
[Test] [Test]
public void TestSpace() public void TestSpace()
{ {
@ -60,59 +61,35 @@ namespace ICSharpCode.NRefactory.Tests.Lexer.VB
Token t = l.NextToken(); Token t = l.NextToken();
Assert.AreEqual(new Point(1, 1), t.Location); Assert.AreEqual(new Point(1, 1), t.Location);
} }
// [Test] [Test]
// public void TestHexNumber() public void TestFloationPointNumber()
// { {
// ILexer l = GenerateLexer("0x142 public"); ILexer l = GenerateLexer("0.142 public");
// Token t = l.NextToken(); Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location); Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken(); t = l.NextToken();
// Assert.AreEqual(new Point(7, 1), t.Location); Assert.AreEqual(new Point(7, 1), t.Location);
// } }
// [Test] [Test]
// public void TestHexNumberChar() public void TestNoFloationPointNumber()
// { {
// ILexer l = GenerateLexer("\'\\x224\' public"); ILexer l = GenerateLexer("5.a");
// Token t = l.NextToken(); Token t = l.NextToken();
// Assert.AreEqual(new Point(1, 1), t.Location); Assert.AreEqual(new Point(1, 1), t.Location);
// t = l.NextToken(); t = l.NextToken();
// Assert.AreEqual(new Point(9, 1), t.Location); Assert.AreEqual(new Point(2, 1), t.Location);
// } t = l.NextToken();
// [Test] Assert.AreEqual(new Point(3, 1), t.Location);
// public void TestFloationPointNumber() }
// { [Test]
// ILexer l = GenerateLexer("0.142 public"); public void TestNumber()
// Token t = l.NextToken(); {
// Assert.AreEqual(new Point(1, 1), t.Location); ILexer l = GenerateLexer("142\nstatic");
// t = l.NextToken(); Token t = l.NextToken();
// Assert.AreEqual(new Point(7, 1), t.Location); t = l.NextToken();
// } t = l.NextToken();
// [Test] Assert.AreEqual(new Point(1, 2), t.Location);
// 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] [Test]
public void TestNumber2() public void TestNumber2()
{ {

Loading…
Cancel
Save