Ejemplo n.º 1
0
        private void Test(string input, IParsingService inLang, string expected, IParsingService outLang, int maxExpand = 0xFFFF)
        {
            var lemp       = NewLemp(maxExpand);
            var inputCode  = new RVList <LNode>(inLang.Parse(input, _sink));
            var results    = lemp.ProcessSynchronously(inputCode);
            var expectCode = outLang.Parse(expected, _sink);

            if (!results.SequenceEqual(expectCode))
            {                   // TEST FAILED, print error
                string resultStr = results.Select(n => outLang.Print(n, _sink)).Join("\n");
                Assert.AreEqual(TestCompiler.StripExtraWhitespace(expected),
                                TestCompiler.StripExtraWhitespace(resultStr));
            }
        }
Ejemplo n.º 2
0
        protected void Test(string input, IParsingService inLang, string expected, IParsingService outLang, int maxExpand = 0xFFFF)
        {
            var lemp = NewLemp(maxExpand, inLang);

            using (ParsingService.PushCurrent(inLang))
            {
                var inputCode  = new VList <LNode>(inLang.Parse(input, MessageSink.Current));
                var results    = lemp.ProcessSynchronously(inputCode);
                var expectCode = outLang.Parse(expected, MessageSink.Current);
                if (!results.SequenceEqual(expectCode))
                {                       // TEST FAILED, print error
                    string resultStr = results.Select(n => outLang.Print(n)).Join("\n");
                    Assert.AreEqual(TestCompiler.StripExtraWhitespace(expected),
                                    TestCompiler.StripExtraWhitespace(resultStr));
                    // In some tests, the text is equal even though the trees are different,
                    // typically because of differences in #trivia attributes between the two.
                    Console.WriteLine();                     // it's OK, but print a hint that this occurred.
                }
            }
        }
Ejemplo n.º 3
0
		private void Test(string input, IParsingService inLang, string expected, IParsingService outLang, int maxExpand = 0xFFFF)
		{
			var lemp = NewLemp(maxExpand);
			var inputCode = new RVList<LNode>(inLang.Parse(input, _sink));
			var results = lemp.ProcessSynchronously(inputCode);
			var expectCode = outLang.Parse(expected, _sink);
			if (!results.SequenceEqual(expectCode))
			{	// TEST FAILED, print error
				string resultStr = results.Select(n => outLang.Print(n, _sink)).Join("\n");
				Assert.AreEqual(TestCompiler.StripExtraWhitespace(expected), 
				                TestCompiler.StripExtraWhitespace(resultStr));
			}
		}
Ejemplo n.º 4
0
 public static string Print(this IParsingService self, LNode node)
 {
     return(self.Print(node, MessageSink.Current));
 }