Beispiel #1
0
        public void Compile_parameterless_int32_method_succeeds()
        {
            var position            = new TextPosition(280, 14, 8);
            var syntax              = MakeParameterlessMethod(Visibility.Private, "int32", position);
            var diagnostics         = new TestingDiagnosticSink();
            var declarationProvider = new TestingSingleFileDeclarationProvider();

            var result = MethodDeclarationCompiler.Compile(syntax, "long::ns", "int32.cle", 8, declarationProvider, diagnostics);

            Assert.That(diagnostics.Diagnostics, Is.Empty);
            Assert.That(result, Is.InstanceOf <NativeMethodDeclaration>());
            Assert.That((result as NativeMethodDeclaration) !.IsEntryPoint, Is.False);
            Assert.That(result !.ReturnType, Is.EqualTo(SimpleType.Int32));
            Assert.That(result.Visibility, Is.EqualTo(Visibility.Private));
            Assert.That(result.FullName, Is.EqualTo("long::ns::MethodName"));
            Assert.That(result.DefiningFilename, Is.EqualTo("int32.cle"));
            Assert.That(result.DefinitionPosition, Is.EqualTo(position));
            Assert.That(result.BodyIndex, Is.EqualTo(8));
        }
Beispiel #2
0
        public void Compile_parameterless_bool_method_succeeds()
        {
            var position            = new TextPosition(13, 3, 4);
            var syntax              = MakeParameterlessMethod(Visibility.Public, "bool", position);
            var diagnostics         = new TestingDiagnosticSink();
            var declarationProvider = new TestingSingleFileDeclarationProvider();

            var result = MethodDeclarationCompiler.Compile(syntax, "Namespace", "bool.cle", 7, declarationProvider, diagnostics);

            Assert.That(diagnostics.Diagnostics, Is.Empty);
            Assert.That(result, Is.InstanceOf <NativeMethodDeclaration>());
            Assert.That((result as NativeMethodDeclaration) !.IsEntryPoint, Is.False);
            Assert.That(result !.ReturnType, Is.EqualTo(SimpleType.Bool));
            Assert.That(result.Visibility, Is.EqualTo(Visibility.Public));
            Assert.That(result.FullName, Is.EqualTo("Namespace::MethodName"));
            Assert.That(result.DefiningFilename, Is.EqualTo("bool.cle"));
            Assert.That(result.DefinitionPosition, Is.EqualTo(position));
            Assert.That(result.BodyIndex, Is.EqualTo(7));
        }