コード例 #1
0
        public void Resolve_CalledTwiceFirstCallResolvesTypeNameSecondCallDoesNotResolve_ReturnsNull()
        {
            string code = "a = Class1()";

            PythonLocalVariableResolver resolver = CreateResolver();

            resolver.Resolve("a", code);
            string typeName = resolver.Resolve("b", code);

            Assert.IsNull(typeName);
        }
コード例 #2
0
        public void Resolve_FieldHasNoReturnType_DoesNotThrowNullReferenceException()
        {
            MockProjectContent projectContent = new MockProjectContent();

            UnitTestingUtils.MockClass c = new UnitTestingUtils.MockClass(projectContent, "Test");
            projectContent.SetClassToReturnFromGetClass("self", c);
            DefaultField field = c.AddField("randomNumber");

            field.ReturnType = null;
            ParseInformation parseInfo = new ParseInformation(c.CompilationUnit);

            ExpressionResult            expression            = new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default);
            PythonClassResolver         classResolver         = new PythonClassResolver();
            PythonLocalVariableResolver localVariableResolver = new PythonLocalVariableResolver(classResolver);
            PythonMemberResolver        resolver = new PythonMemberResolver(classResolver, localVariableResolver);

            PythonResolverContext context = new PythonResolverContext(parseInfo, expression, "class Test:\r\npass");

            Assert.DoesNotThrow(delegate { resolver.Resolve(context); });
        }
コード例 #3
0
        void Resolve(string variableName, string code)
        {
            PythonLocalVariableResolver resolver = CreateResolver();

            typeName = resolver.Resolve(variableName, code);
        }