当前位置: 首页>>代码示例>>C#>>正文


C# Cursor.Advance方法代码示例

本文整理汇总了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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:8,代码来源:TypedExpressionTests.cs

示例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"));
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:8,代码来源:CodeSpanTests.cs

示例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);
            }
        }
开发者ID:chromaton,项目名称:Chromaton,代码行数:34,代码来源:BrainfuckLexer.cs

示例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>());
        }
开发者ID:chromaton,项目名称:Chromaton,代码行数:9,代码来源:CursorTests.cs

示例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);
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:RuleTests.cs

示例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()));
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:CursorTests.cs

示例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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:IdentifierTests.cs

示例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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:CodeSpanTests.cs

示例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);
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:GrammarTests.cs

示例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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:GrammarTests.cs

示例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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:7,代码来源:LiteralExpressionTests.cs

示例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>());
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:8,代码来源:QuantifierTests.cs

示例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()));
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs

示例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);
        }
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs

示例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);
        }
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:9,代码来源:ParseResultTests.cs


注:本文中的Cursor.Advance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。