Esempio n. 1
0
        public void TestFindEnclosingTokens_Char()
        {
            var testInput   = @"open something named{ accessMod type name { someStatement; someOtherStatement; accessMod type name(someArg){someBody;} somefinalStatement; }}";
            var testSubject = new NoFuture.Tokens.XDocFrame();
            var testResults = testSubject.FindEnclosingTokens(testInput, '{', '}');

            Assert.IsNotNull(testResults);
            Assert.AreNotEqual(0, testResults.Count);
            Assert.AreEqual(3, testResults.Count);

            foreach (var t in testResults)
            {
                Console.WriteLine(string.Format("{0},{1}", t.Start, t.End));
            }
        }
Esempio n. 2
0
        public void TestFindEnclosingTokens_Word()
        {
            var testWordStart = "begin";
            var testWordEnd   = "end";
            var testInput     =
                @"some statement; begin somekindOfEnclosure begin firstStatement; secondStatement; end anotherStatement; end more stuff";

            var testSubject = new NoFuture.Tokens.XDocFrame();
            var testResults = testSubject.FindEnclosingTokens(testInput, testWordStart, testWordEnd);

            Assert.IsNotNull(testResults);
            Assert.AreNotEqual(0, testResults.Count);


            foreach (var t in testResults)
            {
                Console.WriteLine(string.Format("{0},{1}", t.Start, t.End));
                Console.WriteLine(testInput.Substring(t.Start, testWordStart.Length));
                Console.WriteLine(testInput.Substring(t.End - testWordEnd.Length, testWordEnd.Length));
            }
        }