Exemplo n.º 1
0
        public void CheckParserCobol85()
        {
            TestTokenSource.Check_CobolCharStream();
            TestTokenSource.Check_CobolTokenSource();
            TestTokenSource.Check_CobolTokenSource_WithStartToken();

            // Test the recognition of potentially ambiguous CodeElements which begin with the same first Token
            TestCodeElements.Check("AT");
            TestCodeElements.Check("END");
            TestCodeElements.Check("NOT");
            TestCodeElements.Check("ON");
            // TO DO -> fix new identifier parsing :
            TestCodeElements.Check_DISPLAYCodeElements();
            TestCodeElements.Check_EXITCodeElements();
            TestCodeElements.Check_IDCodeElements();
            TestCodeElements.Check_UDWCodeElements();
            TestCodeElements.Check_WHENCodeElements();

            TestCodeElements.Check_HeaderCodeElements();
            TestCodeElements.Check_IdentificationCodeElements();
            TestCodeElements.Check_ParagraphCodeElements();
            TestCodeElements.Check_EntryCodeElements();
            TestParser.Check_BeforeAfterInsertion();
            TestParser.Check_BeforeAfterInsertionBatched();

            var errors    = new System.Collections.Generic.List <Exception>();
            int nbOfTests = 0;

            string[] extensions         = { ".cbl", ".pgm" };
            string[] compilerExtensions = extensions.Concat(new[] { ".cpy" }).ToArray();

            foreach (string directory in Directory.GetDirectories(sampleRoot))
            {
                var dirname = Path.GetFileName(directory);

                Console.WriteLine("Entering directory \"" + dirname + "\" [" + string.Join(", ", extensions) + "]:");
                var folderTester = new FolderTester(sampleRoot, resultRoot, directory, extensions, compilerExtensions);
                try { folderTester.Test(); }
                catch (Exception ex) { errors.Add(ex); }
                nbOfTests += folderTester.GetTestCount();
                Console.WriteLine();
            }

            Console.Write("Number of tests: " + nbOfTests + "\n");
            Assert.IsTrue(nbOfTests > 0, "No tests found");

            if (errors.Count > 0)
            {
                var str = new System.Text.StringBuilder();
                foreach (var ex in errors)
                {
                    str.Append(ex.Message);
                }
                throw new Exception(str.ToString());
            }
        }