Пример #1
0
        public void ParseModule_parses_two_files_with_errors_in_both()
        {
            const string source1 = @"namespace Test";
            const string source2 = @"namespace Test;
public int32 Func {}";

            var sourceProvider = new TestingSourceFileProvider();

            sourceProvider.Add(".", "main.cle", source1);
            sourceProvider.Add(".", "other.cle", source2);

            var compilation = new Compilation();

            CompilerDriver.ParseModule(".", compilation, sourceProvider, out var syntaxTrees);

            sourceProvider.AssertFileWasRead("main.cle");
            sourceProvider.AssertFileWasRead("other.cle");
            Assert.That(compilation.Diagnostics, Has.Exactly(2).Items);
            Assert.That(syntaxTrees, Is.Empty);

            Assert.That(compilation.Diagnostics[0].Module, Is.EqualTo("."));
            Assert.That(compilation.Diagnostics[0].Filename, Is.EqualTo("main.cle"));
            Assert.That(compilation.Diagnostics[0].Code, Is.EqualTo(DiagnosticCode.ExpectedSemicolon));

            Assert.That(compilation.Diagnostics[1].Module, Is.EqualTo("."));
            Assert.That(compilation.Diagnostics[1].Filename, Is.EqualTo("other.cle"));
            Assert.That(compilation.Diagnostics[1].Code, Is.EqualTo(DiagnosticCode.ExpectedParameterList));
        }
Пример #2
0
        public void ParseModule_parses_two_files_successfully()
        {
            const string source1 = @"namespace Test;
private int32 PrivateFunc() {}
internal bool ProtectedFunc() {}
public void PublicFunc() {}";
            const string source2 = @"namespace Test;
public int32 OneMoreFunc() {}";

            var sourceProvider = new TestingSourceFileProvider();

            sourceProvider.Add(".", "main.cle", source1);
            sourceProvider.Add(".", "other.cle", source2);

            var compilation = new Compilation();

            CompilerDriver.ParseModule(".", compilation, sourceProvider, out var syntaxTrees);

            sourceProvider.AssertFileWasRead("main.cle");
            sourceProvider.AssertFileWasRead("other.cle");
            Assert.That(compilation.Diagnostics, Is.Empty);
            Assert.That(syntaxTrees, Has.Exactly(2).Items);
        }