Esempio n. 1
0
 public void Number_Recognition_Check()
 {
     TestUtility.CheckFile(testFileName, Stage.Ust, out RootUst ust);
     Assert.IsTrue(ust.AnyDescendantOrSelf(d => d is IntLiteral));
     Assert.IsTrue(ust.AnyDescendantOrSelf(d => d is LongLiteral));
     Assert.IsTrue(ust.AnyDescendantOrSelf(d => d is BigIntLiteral));
 }
Esempio n. 2
0
        public void Parse_SyntaxErrorFileCSharp_CatchErrors()
        {
            var logger = new TestLogger();

            TestUtility.CheckFile("ParseError.cs", Stage.ParseTree, logger, true);

            Assert.AreEqual(7, logger.ErrorCount);
        }
Esempio n. 3
0
        public void Match_HtmlTestPatterns_MatchedExpected()
        {
            IReadOnlyList <IMatchResultBase> result = TestUtility.CheckFile("Patterns.html", Stage.Match,
                                                                            isIgnoreFilenameWildcards: true);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(TextSpan.FromBounds(94, 102), ((MatchResult)result[0]).TextSpan);
            var secondResult = (MatchResult)result[1];

            Assert.AreEqual(TextSpan.FromBounds(71, 85), secondResult.TextSpans[0]);
            Assert.AreEqual(TextSpan.FromBounds(127, 135), secondResult.TextSpans[1]);
        }
Esempio n. 4
0
        public void Convert_JavaPatternsWithErrors_MatchedResultsEqual()
        {
            var patternsLogger = new LoggerMessageCounter();

            TestUtility.CheckFile("Patterns.java", Stage.Match, patternsLogger);

            var patternWithErrorsLogger = new LoggerMessageCounter();

            TestUtility.CheckFile("PatternsWithParseErrors.java", Stage.Match, patternWithErrorsLogger, true);

            Assert.AreEqual(-1, patternWithErrorsLogger.InfoMessageCount - patternsLogger.InfoMessageCount);
        }
Esempio n. 5
0
        public void Convert_PhpPatternsWithErrors_MatchedResultsEqual()
        {
            var patternsLogger = new TestLogger();

            TestUtility.CheckFile("Patterns.php", Stage.Match, patternsLogger);

            var patternWithErrorsLogger = new TestLogger();

            TestUtility.CheckFile("PatternsWithParseErrors.php", Stage.Match, patternWithErrorsLogger, true);

            Assert.AreEqual(patternsLogger.InfoMessageCount, patternWithErrorsLogger.InfoMessageCount);
        }
Esempio n. 6
0
        public void Convert_CSharp_BaseTypesExist()
        {
            string fileName        = Path.Combine(TestUtility.GrammarsDirectory, "csharp", "not-ready-examples", "AllInOne.cs");
            var    workflowResults = TestUtility.CheckFile(fileName, Stage.Ust);
            var    ust             = workflowResults.Usts.First();
            bool   result          = ust.AnyDescendant(descendant =>
            {
                return(descendant is TypeDeclaration typeDeclaration &&
                       typeDeclaration.BaseTypes.Any(type => type.TypeText == nameof(IDisposable)));
            });

            Assert.IsTrue(result, "Ust doesn't contain type declaration node with IDisposable base type");
        }
Esempio n. 7
0
        public void Convert_Java_BaseTypesExist()
        {
            string fileName        = Path.Combine(TestUtility.GrammarsDirectory, "java", "examples", "AllInOne7.java");
            var    workflowResults = TestUtility.CheckFile(fileName, Stage.Ust);
            var    ust             = workflowResults.Usts.First();
            bool   result          = ust.AnyDescendant(descendant =>
            {
                return(descendant is TypeDeclaration typeDeclaration &&
                       typeDeclaration.BaseTypes.Any(type => type.TypeText == "ActionListener"));
            });

            Assert.IsTrue(result, "Ust doesn't contain type declaration node with ActionListener base type");
        }
Esempio n. 8
0
        public void Check_AllDescendants_HaveParentsAfterConvert()
        {
            string         fileName = Path.Combine(TestUtility.GrammarsDirectory, "csharp", "not-ready-examples", "AllInOne.cs");
            WorkflowResult result   = TestUtility.CheckFile(fileName, Stage.Ust);

            IEnumerable <Ust> descendantsExceptFirst = result.Usts.First().WhereDescendants().Skip(1);

            foreach (var descendant in descendantsExceptFirst)
            {
                if (!(descendant is RootUst))
                {
                    Assert.IsNotNull(descendant.Parent);
                }
            }
        }
Esempio n. 9
0
 public void Parse_AspxFile_WithoutErrors(string fileName)
 {
     TestUtility.CheckFile(fileName, Stage.Ust);
 }
Esempio n. 10
0
 public void Convert_CSharpAllInOne_WithoutErrors()
 {
     TestUtility.CheckFile(Path.Combine(TestUtility.GrammarsDirectory, "csharp", "not-ready-examples", "AllInOne.cs"), Stage.Ust);
 }
Esempio n. 11
0
 public void Parser_JavaFile_WithoutErrors(string fileName)
 {
     TestUtility.CheckFile(Path.Combine(TestUtility.GrammarsDirectory, "java", "examples", fileName), Stage.ParseTree);
 }
Esempio n. 12
0
 public void Parse_JavaSyntaxErrorFile_CatchErrors()
 {
     TestUtility.CheckFile("ParseError.java", Stage.ParseTree, shouldContainsErrors: true);
 }
Esempio n. 13
0
        public void Check_Array_Initializations()
        {
            string fileName = Path.Combine(TestUtility.TestsDataPath, "ArrayExamples.cs");

            TestUtility.CheckFile(fileName, Stage.Ust, out RootUst ust);
        }
Esempio n. 14
0
 public void Convert_Java_WithoutErrors(string fileName)
 {
     TestUtility.CheckFile(Path.Combine(TestUtility.GrammarsDirectory, "java", "examples", fileName), Stage.Ust,
                           maxStackSize: fileName == "ManyStringsConcat.java" ? 4000000 : 0);
 }
Esempio n. 15
0
 public void Convert_TSqlPattern_WithoutErrors()
 {
     TestUtility.CheckFile(Path.Combine(TestUtility.TestsDataPath, "tsql_patterns.sql"), Stage.Ust,
                           language: Language.TSql);
 }
Esempio n. 16
0
 public void Parse_CSharpWithRoslyn()
 {
     TestUtility.CheckFile(Path.Combine(TestUtility.GrammarsDirectory, "csharp", "not-ready-examples", "AllInOne.cs"),
                           Stage.ParseTree);
 }