Beispiel #1
0
        public void ExpressionCountAndOr()
        {
            string code = "((x > 2) && (y>2) || (b))";

              LookAheadLangParser parser = LookAheadLangParser.CreateCppParser(TestUtil.GetTextStream(code));

              BlockAnalyzer analyzer = new BlockAnalyzer(parser);

              Assert.AreEqual(2, analyzer.CalcNumExpressionConditions());
        }
Beispiel #2
0
        public void ExpressionCounterConsumesExpression()
        {
            string code = "((x))(y)";

              LookAheadLangParser parser = LookAheadLangParser.CreateCppParser(TestUtil.GetTextStream(code));

              BlockAnalyzer analyzer = new BlockAnalyzer(parser);

              analyzer.CalcNumExpressionConditions();

              Assert.AreEqual("(", parser.NextKeyword());
              Assert.AreEqual("y", parser.NextKeyword());
              Assert.AreEqual(")", parser.NextKeyword());
        }
Beispiel #3
0
        public void ConditionalExpressionEmbeddedCalls()
        {
            string code = "" +
            "(x != this.parser.PeekNext()) \r\n" +
            "this.parser.NextKeyword()";

              LookAheadLangParser parser = LookAheadLangParser.CreateCppParser(TestUtil.GetTextStream(code));
              BlockAnalyzer analyzer = new BlockAnalyzer(parser);

              analyzer.CalcNumExpressionConditions();

              Assert.AreEqual("this.parser.NextKeyword", parser.NextKeyword());
        }