本文整理汇总了C#中Cursor.Advance方法的典型用法代码示例。如果您正苦于以下问题:C# Cursor.Advance方法的具体用法?C# Cursor.Advance怎么用?C# Cursor.Advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cursor
的用法示例。
在下文中一共展示了Cursor.Advance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor_WhenGivenANullExpression_ThrowsException
public void Constructor_WhenGivenANullExpression_ThrowsException()
{
var start = new Cursor("OK");
var end = start.Advance(2);
var codeSpan = new CodeSpan("OK", start, end);
Assert.That(() => new TypedExpression(codeSpan, null), Throws.InstanceOf<ArgumentNullException>());
}
示例2: ToString_WhenConstructedWithANullValue_ReturnsTheCodeVerbatim
public void ToString_WhenConstructedWithANullValue_ReturnsTheCodeVerbatim()
{
var start = new Cursor("OK");
var end = start.Advance(2);
var codeSpan = new CodeSpan("OK", start, end);
Assert.That(codeSpan.ToString(), Is.EqualTo("OK"));
}
示例3: Tokenize
protected override IEnumerable<Token> Tokenize(string source)
{
Cursor c = new Cursor(source);
while (c.Offset < source.Length)
{
var currentChar = source[c.Offset];
if (operators.Contains(currentChar))
{
yield return new Token(c.Offset, c.Offset + 1, "Operator.Symbol");
c.Advance(1);
continue;
}
if (grouping.Contains(currentChar))
{
yield return new Token(c.Offset, c.Offset + 1, "Grouping.Statements");
c.Advance(1);
continue;
}
var match = whitespace.Match(source, c.Offset);
if (match.Success && match.Index == c.Offset)
{
yield return new Token(c.Offset, c.Offset + match.Length, "Whitespace.Insignificant");
c.Advance(match.Length);
continue;
}
match = nonOperator.Match(source, c.Offset);
yield return new Token(c.Offset, c.Offset + match.Length, "Comment.Block");
c.Advance(match.Length);
}
}
示例4: Advance_WhenAdvancingPastTheEndOfTheText_ThrowsException
public void Advance_WhenAdvancingPastTheEndOfTheText_ThrowsException()
{
var subject = "OK_OK_OK_OK_OK";
var cursor = new Cursor(subject);
cursor.Advance(subject.Length);
Assert.That(() => cursor.Advance(1), Throws.InstanceOf<InvalidOperationException>());
}
示例5: Constructor_WhenGivenANullFlagsCollection_DoesNotThrow
public void Constructor_WhenGivenANullFlagsCollection_DoesNotThrow()
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new Rule(new Identifier("OK", start, end), new WildcardExpression(), null), Throws.Nothing);
}
示例6: GetHashCode_WithEqualSubjectsAndIndexesAndStateKey_ReturnsSameValue
public void GetHashCode_WithEqualSubjectsAndIndexesAndStateKey_ReturnsSameValue([Values(0, 1, 2)] int index)
{
var subjectA = new Cursor("OK", index);
var subjectB = subjectA.Advance(0);
Assert.That(subjectB.GetHashCode(), Is.EqualTo(subjectA.GetHashCode()));
}
示例7: Constructor_WhenGivenANullExpression_ThrowsException
public void Constructor_WhenGivenANullExpression_ThrowsException()
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new Identifier(null, start, end), Throws.InstanceOf<ArgumentNullException>());
}
示例8: Constructor_WhenGivenNullStartCursor_ThrowsException
public void Constructor_WhenGivenNullStartCursor_ThrowsException()
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new CodeSpan("OK", null, end), Throws.InstanceOf<ArgumentNullException>());
}
示例9: Constructor_WhenGivenANullSettingsCollection_DoesNotThrow
public void Constructor_WhenGivenANullSettingsCollection_DoesNotThrow()
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new Grammar(new Rule[0], null, end), Throws.Nothing);
}
示例10: Constructor_WhenGivenANullCollectionOfRules_ThrowsException
public void Constructor_WhenGivenANullCollectionOfRules_ThrowsException()
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new Grammar(null, new Dictionary<Identifier, object>(), end), Throws.InstanceOf<ArgumentNullException>());
}
示例11: Constructor_WhenGivenANullValue_ThrowsException
public void Constructor_WhenGivenANullValue_ThrowsException(bool ignoreCase, bool fromResource)
{
var start = new Cursor("OK");
var end = start.Advance(2);
Assert.That(() => new LiteralExpression(start, end, null, ignoreCase, fromResource), Throws.InstanceOf<ArgumentNullException>());
}
示例12: Constructor_WhenGivenANullStartCursor_ThrowsException
public void Constructor_WhenGivenANullStartCursor_ThrowsException(int min, int? max, bool nullDelimiter)
{
var start = new Cursor("OK");
var end = start.Advance(2);
var delimiter = nullDelimiter ? null : new WildcardExpression();
Assert.That(() => new Quantifier(null, end, min, max, delimiter), Throws.InstanceOf<ArgumentNullException>());
}
示例13: GetHashCode_WithEqualValuesAndCursors_ReturnsSameValue
public void GetHashCode_WithEqualValuesAndCursors_ReturnsSameValue([Values(0, 1, 2)] int index)
{
var start = new Cursor("OK");
var end = start.Advance(index);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = new ParseResult<int>(start, end, 0);
Assert.That(subjectB.GetHashCode(), Is.EqualTo(subjectA.GetHashCode()));
}
示例14: OpEquality_WithNullReferenceOnRight_ReturnsFalse
public void OpEquality_WithNullReferenceOnRight_ReturnsFalse()
{
var start = new Cursor("OK", 0);
var end = start.Advance(1);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = (ParseResult<int>)null;
Assert.That(subjectA == subjectB, Is.False);
}
示例15: OpEquality_WithEqualValuesAndCursors_ReturnsTrue
public void OpEquality_WithEqualValuesAndCursors_ReturnsTrue()
{
var start = new Cursor("OK", 0);
var end = start.Advance(1);
var subjectA = new ParseResult<int>(start, end, 0);
var subjectB = new ParseResult<int>(start, end, 0);
Assert.That(subjectA == subjectB, Is.True);
}