Exemple #1
0
        public void FindAssignStatementsTest()
        {
            var methodBody = GenerateMethodBody(PythonCodeGenerator.GenerateDefaultAssignmentStatement());
            var finder     = BuildFinder(methodBody);

            var assignStatements = finder.FindAssignStatements();

            Assert.AreEqual(1, assignStatements.Count());
        }
        private string GenerateMethodBody(int statementsCount)
        {
            var statements = new List <string>();

            for (var i = 0; i < statementsCount; i++)
            {
                statements.Add(PythonCodeGenerator.GenerateDefaultAssignmentStatement());
            }

            return(PythonCodeGenerator.GenerateFunctionBody(statements));
        }
Exemple #3
0
        public void CountOfDirectStatementsInBodyTest()
        {
            var assignmentStatement = PythonCodeGenerator.GenerateDefaultAssignmentStatement();
            var embeddedStatement   = PythonCodeGenerator.GenerateDefaultCompoundStatement(2);
            var returnStatement     = PythonCodeGenerator.GenerateDefaultReturnStatement();

            string[] statements = { assignmentStatement, embeddedStatement, returnStatement };
            var      methodBody = GenerateMethodBody(statements);

            var finder = BuildFinder(methodBody);

            var statementsCount = finder.CountOfDirectStatementsInBody();

            Assert.AreEqual(3, statementsCount);
        }