Пример #1
0
        public void TheProblem_OverlapWithPartOfItself()
        {
            // Content 3: aa bb cc dd ee ff ee dd cc bb aa aa bb cc dd
            // Content 4: aa bb cc dd cc
            // Content 5: cc dd ee ff

            Console.WriteLine("dd ee * ee");

            // dd ee * ee => (dd ee) * (ee)  does not work as expected
            var lm = MakeSpan(0, dd, ee);
            var rm = MakeSpan(0, ee);
            var q1 = MakeSpan(1, lm, rm);

            TestIndex.AssertQuery(q1, 3, 5);

            // dd ee * ee => dd (ee * ee) works, but only because nothing follows the last ee
            var q2 = MakeSpan(0, dd, MakeSpan(1, ee, ee));

            TestIndex.AssertQuery(q2, 3);

            // (dd ee) * (ee - (dd ee))
            var not = new SpanNotQuery(ee, MakeSpan(0, dd, ee));
            var q3  = MakeSpan(1, lm, not);

            TestIndex.AssertQuery(q3, 3);
        }
Пример #2
0
        public void OverlappingSpans_Part3()
        {
            // If you rewrite it as (cc (dd ** (dd cc))) it matches only 4!
            Console.WriteLine("(cc (dd ** (dd cc)))");
            var q3 = MakeSpan(0, cc, MakeSpan(16, dd, MakeSpan(0, dd, cc)));

            TestIndex.AssertQuery(q3, 4);
        }
Пример #3
0
        public void OverlappingSpans_Part2()
        {
            // If you rewrite the query as (cc (dd ** dd) cc) it doesn't work at all
            // because the inner match is to great
            var gap = MakeSpan(16, dd, dd);
            var q2  = MakeSpan(0, cc, gap, cc);

            TestIndex.AssertQuery(q2);
        }
Пример #4
0
        public void OverlappingSpans_Part1()
        {
            // A SpanQuery clause can overlap its preceding clause if its
            // slope is greater than 0
            // In the following example ((cc dd) ** (dd cc)) matches content 3 and 4!
            var lm = MakeSpan(0, cc, dd);
            var rm = MakeSpan(0, dd, cc);
            var q1 = MakeSpan(16, lm, rm);

            TestIndex.AssertQuery(q1, 3, 4);
        }
Пример #5
0
        public void OverlappingSpans_Part5()
        {
            // Interestingly, the following does not work with SpanNotQueries
            // dd ee * ee => ((dd ee) - ee) * ee never matches because the
            // first span (dd ee) always overlaps with ee
            var span = MakeSpan(0, dd, ee);

            TestIndex.AssertQuery(span, 3, 5);
            var q5 = new SpanNotQuery(span, ee);

            TestIndex.AssertQuery(q5);
        }
Пример #6
0
        public void OverlappingSpans_Part4()
        {
            var lm = MakeSpan(0, cc, dd);
            var rm = MakeSpan(0, dd, cc);

            // Rewriting with SpanNotQueries works!
            Console.WriteLine("((cc dd) - (dd cc)) ** (dd cc)");
            var not = new SpanNotQuery(lm, rm);
            var q4  = MakeSpan(16, not, rm);

            TestIndex.AssertQuery(q4, 3);

            // This is now implemented int the parser
            TestIndex.AssertQuery(Content("cc dd ** dd cc"), 3);
        }
Пример #7
0
        public void OverlappingSpans_Part6()
        {
            // But the reverse ways of excluding spans works
            // (dd ee * ee) => (dd ee) * (ee -(dd ee))
            var span = MakeSpan(0, dd, ee);
            var not  = new SpanNotQuery(ee, span);
            var q6   = MakeSpan(1, span, not);

            TestIndex.AssertQuery(q6, 3);

            // The parser now implements this strategy
            var q = Content("dd ee * ee");

            TestIndex.AssertQuery(Content("dd ee * ee"), 3);
        }
Пример #8
0
 public void SingleGap()
 {
     TestIndex.AssertQuery(PathQuery("/shared/general/FileIO/*.xml"), 4);
 }
Пример #9
0
 public void PathGap()
 {
     TestIndex.AssertQuery(PathQuery("FileIO/**/fileio.cpp"), 1, 8, 15);
     TestIndex.AssertQuery(PathQuery("/woanders/FileIO/**/fileio.*"), 15, 16);
     TestIndex.AssertQuery(PathQuery("shared/**/fileio"), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
 }
Пример #10
0
 public void LeadingWildcards()
 {
     TestIndex.AssertQuery(PathQuery("*.cs"), 0, 14, 17);
 }
Пример #11
0
 public void FindPathOnly()
 {
     TestIndex.AssertQuery(PathQuery("flip/"), 5);
 }
Пример #12
0
 public void FindPathOrFile()
 {
     TestIndex.AssertQuery(PathQuery("flip"), 5, 14);
 }
Пример #13
0
 public void CsExtension()
 {
     TestIndex.AssertQuery(PathQuery(".cs"), 0, 14, 17);
     TestIndex.AssertQuery(PathQuery("cs"), 0, 14, 17);
 }
Пример #14
0
 public void StartAtRoot()
 {
     TestIndex.AssertQuery(PathQuery("/shared/"), 1, 2, 3, 4, 5, 6, 7);
 }
Пример #15
0
 public void EmptyQuery()
 {
     TestIndex.AssertQuery(PathQuery(""));
 }
Пример #16
0
 public void PartialPath()
 {
     TestIndex.AssertQuery(PathQuery("selt.sam/source/form1.design.cs"), 17);
 }