4 changed files with 86 additions and 2 deletions
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.Scripting.Tests.Utils; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
using UnitTestingUtils = UnitTesting.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveMemberWhenFieldHasNoReturnTypeTests |
||||
{ |
||||
[Test] |
||||
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); }); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveRandomRandintTests : ResolveTestsBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
return new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"import random\r\n" + |
||||
"\r\n" + |
||||
"class Test:\r\n" + |
||||
" def __init__(self):\r\n" + |
||||
" self.randomNumber = random.random()\r\n" + |
||||
" self.randomNumber.randint\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void Resolve_RandomModuleCannotBeFound_NoNullRefererenceExceptionThrown() |
||||
{ |
||||
Assert.IsNotNull(resolveResult as PythonMethodGroupResolveResult); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue