Browse Source

Fixed unit tests with leading dots & integer at eol.

newNRvisualizers
Mike Krüger 15 years ago
parent
commit
d5ead16000
  1. 8
      ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs
  2. 7
      ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs
  3. 3
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/PrimitiveExpressionTests.cs

8
ICSharpCode.NRefactory.CSharp/Parser/mcs/cs-tokenizer.cs

@ -1514,6 +1514,7 @@ namespace Mono.CSharp
#endif #endif
number_pos = 0; number_pos = 0;
var loc = Location; var loc = Location;
bool hasLeadingDot = c == '.';
if (c >= '0' && c <= '9'){ if (c >= '0' && c <= '9'){
if (c == '0'){ if (c == '0'){
@ -1545,7 +1546,6 @@ namespace Mono.CSharp
putback ('.'); putback ('.');
number_pos--; number_pos--;
val = res = adjust_int (-1, loc); val = res = adjust_int (-1, loc);
#if FULL_AST #if FULL_AST
res.ParsedValue = reader.ReadChars (read_start, reader.Position - 1); res.ParsedValue = reader.ReadChars (read_start, reader.Position - 1);
#endif #endif
@ -1595,9 +1595,11 @@ namespace Mono.CSharp
} }
val = res; val = res;
#if FULL_AST #if FULL_AST
res.ParsedValue = reader.ReadChars (read_start, reader.Position - (type == TypeCode.Empty ? 1 : 0)); var endPos = reader.Position - (type == TypeCode.Empty ? 1 : 0);
if (reader.GetChar (endPos - 1) == '\r')
endPos--;
res.ParsedValue = reader.ReadChars (hasLeadingDot ? read_start - 1 : read_start, endPos);
#endif #endif
return Token.LITERAL; return Token.LITERAL;

7
ICSharpCode.NRefactory.CSharp/Parser/mcs/support.cs

@ -238,7 +238,12 @@ namespace Mono.CSharp {
return pos < char_count; return pos < char_count;
} }
public char GetChar (int position)
{
return buffer[position];
}
public char[] ReadChars (int fromPosition, int toPosition) public char[] ReadChars (int fromPosition, int toPosition)
{ {
char[] chars = new char[toPosition - fromPosition]; char[] chars = new char[toPosition - fromPosition];

3
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/PrimitiveExpressionTests.cs

@ -49,14 +49,12 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Assert.AreEqual(code, pe.LiteralValue); Assert.AreEqual(code, pe.LiteralValue);
} }
[Ignore("Fixme!")]
[Test] [Test]
public void DoubleWithLeadingDot() public void DoubleWithLeadingDot()
{ {
CheckLiteral(".5e-06", .5e-06); CheckLiteral(".5e-06", .5e-06);
} }
[Ignore("Fixme!")]
[Test] [Test]
public void FloatWithLeadingDot() public void FloatWithLeadingDot()
{ {
@ -228,7 +226,6 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
CheckLiteral(@"'\U00000041'", '\U00000041'); CheckLiteral(@"'\U00000041'", '\U00000041');
} }
[Ignore("Fixme!")]
[Test] [Test]
public void TestPositionOfIntegerAtEndOfLine() public void TestPositionOfIntegerAtEndOfLine()
{ {

Loading…
Cancel
Save