Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1388 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
192 changed files with 4951 additions and 2868 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
To be on the safe side and leave enough space for the future, |
||||
the in-memory size of an assembly used here should be 8 times the disk image size. |
||||
|
||||
Sysinternals Processexplorer can show relocated assemblies in yellow in the DLL View. |
||||
|
||||
adr = 0x5000000 |
||||
def AddModule(kbsize as int): |
||||
print "0x${adr.ToString('x')} - 0x${(adr + 3 * kbsize * 1024).ToString('x')}" |
||||
adr += 8 * kbsize * 1024 |
||||
adr = 0x80000 * System.Math.Ceiling(cast(double,adr) / 0x80000) |
||||
|
||||
def AddModules(*names as (string)): |
||||
for name in names: |
||||
System.Console.Write("${name}:\t") |
||||
AddModule(System.IO.FileInfo("d:\\corsavy\\sharpdevelop\\bin\\" + name + ".dll").Length / 1024) |
||||
|
||||
AssemblyName: startaddress - endaddress |
||||
ICSharpCode.Core: 0x5000000 - 0x504e000 |
||||
ICSharpCode.SharpDevelop: 0x5100000 - 0x5472000 |
||||
ICSharpCode.NRefactory: 0x5a80000 - 0x5b9a000 |
||||
ICSharpCode.TextEditor: 0x5d80000 - 0x5e67000 |
||||
MonoReflectionLoader: 0x6000000 - 0x600c000 |
||||
WeifenLuo.WinFormsUI.Docking: 0x6080000 - 0x6107000 |
||||
ICSharpCode.Build.Tasks: 0x6200000 - 0x621b000 |
||||
|
||||
CSharpBinding: 0x6280000 - 0x62bc000 |
||||
ILAsmBinding: 0x6380000 - 0x639b000 |
||||
VBNetBinding: 0x6400000 - 0x643f000 |
||||
NRefactoryToBooConverter: 0x6500000 - 0x6536000 |
||||
BooBinding: 0x6600000 - 0x664e000 |
||||
|
||||
FormsDesigner: 0x6700000 - 0x676f000 |
||||
ResourceEditor: 0x6880000 - 0x689e000 |
||||
XmlEditor: 0x6900000 - 0x6948000 |
||||
|
||||
ICSharpCode.AddInMananger: 0x6a00000 - 0x6a24000 |
||||
AddInScout: 0x6a80000 - 0x6a8b400 |
||||
CodeCoverage: 0x6b00000 - 0x6b30000 |
||||
TreeListView (debugger): 0x6b80000 - 0x6be6000 |
||||
Debugger.Code: 0x6d00000 - 0x6ddb000 |
||||
Debugger.AddIn: 0x6f80000 - 0x6faa000 |
||||
FileTypeRegisterer: 0x7000000 - 0x7009000 |
||||
HighlightingEditor: 0x7080000 - 0x70ec000 |
||||
HtmlHelp2: 0x7200000 - 0x723f000 |
||||
HtmlHelp2JScriptGlobals: 0x7300000 - 0x7306c00 |
||||
MonoAddIn: 0x7380000 - 0x7395000 |
||||
NAntAddIn: 0x7400000 - 0x7427000 |
||||
PInvokeAddIn: 0x7480000 - 0x749b000 |
||||
RegExpTk: 0x7500000 - 0x7524000 |
||||
SharpQuery: 0x7580000 - 0x75b0000 |
||||
SharpReportCore: 0x7600000 - 0x7654000 |
||||
SharpReport: 0x7700000 - 0x773c000 |
||||
SharpReportAddIn: 0x7800000 - 0x781e000 |
||||
ReportGenerator: 0x7880000 - 0x78a1000 |
||||
StartPage: 0x7900000 - 0x791e000 |
||||
UnitTesting: 0x7980000 - 0x799b000 |
||||
|
||||
Next free address: 0x7a00000 |
||||
|
||||
|
||||
|
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>Grunwald.BooBinding.Tests</RootNamespace> |
||||
<AssemblyName>BooBinding.Tests</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{6FA16499-896F-4C02-BB43-1AF5C6C7C713}</ProjectGuid> |
||||
<OutputPath>..\..\..\..\..\..\bin\UnitTests\</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> |
||||
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> |
||||
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="nunit.framework"> |
||||
<HintPath>..\..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="ResolverTests.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\Project\BooBinding.csproj"> |
||||
<Project>{4AC2D5F1-F671-480C-A075-6BF62B3721B2}</Project> |
||||
<Name>BooBinding</Name> |
||||
</ProjectReference> |
||||
<Content Include="..\..\..\..\..\..\bin\log4net.dll"> |
||||
<Link>log4net.dll</Link> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Content> |
||||
<Content Include="..\..\..\..\..\..\bin\ICSharpCode.Core.dll"> |
||||
<Link>ICSharpCode.Core.dll</Link> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Content> |
||||
<Content Include="..\..\..\..\..\..\bin\ICSharpCode.SharpDevelop.dll"> |
||||
<Link>ICSharpCode.SharpDevelop.dll</Link> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Content> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,417 @@
@@ -0,0 +1,417 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 23.04.2006 |
||||
* Time: 11:33 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using NUnit.Framework; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using Grunwald.BooBinding.CodeCompletion; |
||||
|
||||
namespace Grunwald.BooBinding.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ResolverTests |
||||
{ |
||||
#region Helper
|
||||
T Resolve<T>(string code) where T : ResolveResult |
||||
{ |
||||
return Resolve<T>(code, "/*1*/"); |
||||
} |
||||
|
||||
T Resolve<T>(string code, string marker) where T : ResolveResult |
||||
{ |
||||
return Resolve<T>(normalProg, code, marker); |
||||
} |
||||
|
||||
T Resolve<T>(string prog, string code, string marker) where T : ResolveResult |
||||
{ |
||||
ResolveResult rr = Resolve(prog, new ExpressionResult(code), marker); |
||||
Assert.IsNotNull(rr, "Resolve must not return null"); |
||||
Assert.IsInstanceOfType(typeof(T), rr, "Resolve must return instance of type " + typeof(T).Name); |
||||
return (T)rr; |
||||
} |
||||
|
||||
IProjectContent booLangPC; |
||||
|
||||
public ResolverTests() { |
||||
booLangPC = new ReflectionProjectContent(Assembly.Load("Boo.Lang"), "Boo.Lang.dll"); |
||||
booLangPC.ReferencedContents.Add(ProjectContentRegistry.Mscorlib); |
||||
} |
||||
|
||||
const string fileName = "tempFile.boo"; |
||||
DefaultProjectContent lastPC; |
||||
|
||||
void Register(string prog) |
||||
{ |
||||
DefaultProjectContent pc = new DefaultProjectContent(); |
||||
lastPC = pc; |
||||
ParserService.ForceProjectContent(pc); |
||||
pc.ReferencedContents.Add(ProjectContentRegistry.Mscorlib); |
||||
pc.ReferencedContents.Add(ProjectContentRegistry.WinForms); |
||||
pc.ReferencedContents.Add(booLangPC); |
||||
ICompilationUnit cu = new BooParser().Parse(pc, fileName, prog); |
||||
ParserService.UpdateParseInformation(cu, fileName, false, false); |
||||
cu.Classes.ForEach(pc.AddClassToNamespaceList); |
||||
} |
||||
|
||||
void GetPos(string prog, string marker, out int line, out int column) |
||||
{ |
||||
int index = prog.IndexOf(marker); |
||||
line = 1; |
||||
column = 0; |
||||
for (int i = 0; i < index; i++) { |
||||
column++; |
||||
if (prog[i]=='\n') { |
||||
line++; |
||||
column = 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
ResolveResult Resolve(string prog, ExpressionResult er, string marker) |
||||
{ |
||||
Register(prog); |
||||
int line, column; |
||||
GetPos(prog, marker, out line, out column); |
||||
|
||||
BooResolver r = new BooResolver(); |
||||
return r.Resolve(er, line, column, fileName, prog); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Basic tests
|
||||
const string normalProg = |
||||
"import System\n" + |
||||
"def MyMethod(arg as string):\n" + |
||||
"\tlocalVar = arg\n" + |
||||
"\t/*1*/\n" + |
||||
"\tclosure = { e as string | arg.IndexOf(e) /*inClosure*/ }\n" + |
||||
"\tindex = closure('.')\n" + |
||||
"\t/*2*/\n" + |
||||
"\tclosure2 = def(e as DateTime):\n" + |
||||
"\t\treturn e.Year\n" + |
||||
"\trecursiveClosure = def(myObject):/*inRecursiveClosure*/\n" + |
||||
"\t\treturn recursiveClosure(myObject)\n" + |
||||
"\t/*3*/\n"; |
||||
|
||||
[Test] |
||||
public void MethodParameter() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("arg"); |
||||
Assert.IsTrue(rr.IsParameter); |
||||
Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void LocalVariable() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("localVar"); |
||||
Assert.IsFalse(rr.IsParameter); |
||||
Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void NullCoalescing() |
||||
{ |
||||
ResolveResult rr = Resolve<ResolveResult>("localVar or arg"); |
||||
Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void InnerClassEnum() |
||||
{ |
||||
TypeResolveResult trr = Resolve<TypeResolveResult>("Environment.SpecialFolder"); |
||||
Assert.AreEqual("System.Environment.SpecialFolder", trr.ResolvedClass.FullyQualifiedName); |
||||
|
||||
MemberResolveResult mrr = Resolve<MemberResolveResult>("Environment.SpecialFolder.Desktop"); |
||||
Assert.AreEqual("System.Environment.SpecialFolder.Desktop", mrr.ResolvedMember.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClosureParameter() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("e", "/*inClosure*/"); |
||||
Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName); |
||||
|
||||
Assert.IsNull(Resolve(normalProg, new ExpressionResult("e"), "/*1*/")); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClosureCall() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("closure('.')", "/*2*/"); |
||||
Assert.IsFalse(rr.IsParameter); |
||||
Assert.AreEqual("closure", rr.Field.Name); |
||||
Assert.AreEqual("System.Int32", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClosureCall2() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("closure2(DateTime.Now)", "/*3*/"); |
||||
Assert.IsFalse(rr.IsParameter); |
||||
Assert.AreEqual("closure2", rr.Field.Name); |
||||
Assert.AreEqual("System.Int32", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void RecursiveClosure() |
||||
{ |
||||
// Code-completion cannot work here, test if SharpDevelop is correctly
|
||||
// preventing the StackOverflow.
|
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("recursiveClosure", "/*3*/"); |
||||
Assert.IsFalse(rr.IsParameter); |
||||
Assert.AreEqual("delegate(myObject:Object):?", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClosureTypelessArgument() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>("myObject", "/*inRecursiveClosure*/"); |
||||
Assert.AreEqual("System.Object", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void EqualityOperator() |
||||
{ |
||||
ResolveResult rr = Resolve<ResolveResult>("0 == 0"); |
||||
Assert.AreEqual("System.Boolean", rr.ResolvedType.FullyQualifiedName); |
||||
rr = Resolve<ResolveResult>("0 != 1"); |
||||
Assert.AreEqual("System.Boolean", rr.ResolvedType.FullyQualifiedName); |
||||
rr = Resolve<ResolveResult>("null is null"); |
||||
Assert.AreEqual("System.Boolean", rr.ResolvedType.FullyQualifiedName); |
||||
rr = Resolve<ResolveResult>("object() is not null"); |
||||
Assert.AreEqual("System.Boolean", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void ClassMethodAmbiguity() |
||||
{ |
||||
string prog = |
||||
"class Test:\n" + |
||||
"\tdef constructor():\n" + |
||||
"\t\tpass\n" + |
||||
"class OtherClass:\n" + |
||||
"\tdef Test():\n" + |
||||
"\t\t/*mark*/\n" + |
||||
"\t\tpass\n"; |
||||
MemberResolveResult rr = Resolve<MemberResolveResult>(prog, "Test()", "/*mark*/"); |
||||
Assert.AreEqual("OtherClass.Test", rr.ResolvedMember.FullyQualifiedName); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Regression
|
||||
const string regressionProg = |
||||
"import System\n" + |
||||
"import System.Reflection\n" + |
||||
"def MyMethod(arg as string):\n" + |
||||
"\tif true:\n" + |
||||
"\t\tboo629 = 'hello'\n" + |
||||
"\tfor boo640a in [1, 2, 3]:\n" + |
||||
"\t\tif boo640b = boo640a as FieldInfo: /*640*/\n" + |
||||
"\t\t\tprint boo640b\n" + |
||||
"\t\n" + |
||||
"\t/*1*/\n"; |
||||
|
||||
[Test] |
||||
public void Boo629VariableScope() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>(regressionProg, "boo629", "/*1*/"); |
||||
Assert.AreEqual("System.String", rr.ResolvedType.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void Boo640ConditionalAssignment() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>(regressionProg, "boo640b", "/*1*/"); |
||||
Assert.AreEqual("System.Reflection.FieldInfo", rr.ResolvedType.FullyQualifiedName); |
||||
rr = Resolve<LocalResolveResult>(regressionProg, "boo640a", "/*640*/"); |
||||
Assert.AreEqual("System.Object", rr.ResolvedType.FullyQualifiedName); |
||||
Assert.IsNull(Resolve(regressionProg, new ExpressionResult("boo640a"), "/*1*/")); |
||||
} |
||||
|
||||
[Test] |
||||
public void IndexerRecognition() |
||||
{ |
||||
string prog = |
||||
"class Foo:\n" + |
||||
"\tself[index as int]:\n" + |
||||
"\t\tget:\n" + |
||||
"\t\t\treturn true\n" + |
||||
"def example():\n" + |
||||
"\tfoo = Foo()\n" + |
||||
"\tmybool = foo[1] /*mark*/\n" + |
||||
"\tprint mybool\n"; |
||||
MemberResolveResult rr = Resolve<MemberResolveResult>(prog, "foo[1]", "/*mark*/"); |
||||
Assert.IsTrue(((IProperty)rr.ResolvedMember).IsIndexer); |
||||
Assert.AreEqual("System.Boolean", rr.ResolvedType.FullyQualifiedName); |
||||
LocalResolveResult rr2 = Resolve<LocalResolveResult>(prog, "mybool", "/*mark*/"); |
||||
Assert.AreEqual("System.Boolean", rr2.ResolvedType.FullyQualifiedName); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Nested Classes
|
||||
const string nestedClassProg = |
||||
"class Outer:\n" + |
||||
"\tpublic static outerField = 1\n" + |
||||
"\tpublic class Inner:\n/*inner*/" + |
||||
"\t\tpublic innerField = 2\n" + |
||||
"class Derived(Outer):\n/*derived*/" + |
||||
"\tpublic static derivedField = 3\n" + |
||||
"def Method():\n" + |
||||
"\ti as Outer.Inner\n" + |
||||
"\ti2 as Derived.Inner\n" + |
||||
"\t/*1*/"; |
||||
|
||||
[Test] |
||||
public void NestedClassTypeResolution() |
||||
{ |
||||
TypeResolveResult trr; |
||||
trr = Resolve<TypeResolveResult>(nestedClassProg, "Outer.Inner", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner", trr.ResolvedClass.FullyQualifiedName); |
||||
trr = Resolve<TypeResolveResult>(nestedClassProg, "Inner", "/*inner*/"); |
||||
Assert.AreEqual("Outer.Inner", trr.ResolvedClass.FullyQualifiedName); |
||||
trr = Resolve<TypeResolveResult>(nestedClassProg, "Inner", "/*derived*/"); |
||||
Assert.AreEqual("Outer.Inner", trr.ResolvedClass.FullyQualifiedName); |
||||
trr = Resolve<TypeResolveResult>(nestedClassProg, "Derived.Inner", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner", trr.ResolvedClass.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void NestedClassCtrlSpace() |
||||
{ |
||||
CtrlSpace(nestedClassProg.Replace("/*inner*/", "/*mark*/"), "outerField", "innerField", "Inner", "Outer", "Derived"); |
||||
CtrlSpace(nestedClassProg.Replace("/*derived*/", "/*mark*/"), "outerField", "derivedField", "Inner", "Outer", "Derived"); |
||||
} |
||||
|
||||
[Test] |
||||
public void NestedClassParentStaticField() |
||||
{ |
||||
MemberResolveResult mrr = Resolve<MemberResolveResult>(nestedClassProg, "outerField", "/*inner*/"); |
||||
Assert.AreEqual("Outer.outerField", mrr.ResolvedMember.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void NestedClassCC() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>(nestedClassProg, "i", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner", rr.ResolvedType.FullyQualifiedName); |
||||
bool ok = false; |
||||
foreach (object o in rr.GetCompletionData(lastPC)) { |
||||
IMember m = o as IMember; |
||||
if (m != null && m.Name == "innerField") |
||||
ok = true; |
||||
} |
||||
Assert.IsTrue(ok); |
||||
MemberResolveResult mrr = Resolve<MemberResolveResult>(nestedClassProg, "i.innerField", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner.innerField", mrr.ResolvedMember.FullyQualifiedName); |
||||
} |
||||
|
||||
[Test] |
||||
public void NestedClassCC2() |
||||
{ |
||||
LocalResolveResult rr = Resolve<LocalResolveResult>(nestedClassProg, "i2", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner", rr.ResolvedType.FullyQualifiedName); |
||||
bool ok = false; |
||||
foreach (object o in rr.GetCompletionData(lastPC)) { |
||||
IMember m = o as IMember; |
||||
if (m != null && m.Name == "innerField") |
||||
ok = true; |
||||
} |
||||
Assert.IsTrue(ok); |
||||
MemberResolveResult mrr = Resolve<MemberResolveResult>(nestedClassProg, "i2.innerField", "/*1*/"); |
||||
Assert.AreEqual("Outer.Inner.innerField", mrr.ResolvedMember.FullyQualifiedName); |
||||
} |
||||
#endregion
|
||||
|
||||
#region CtrlSpace
|
||||
void CtrlSpace(string prog, params string[] expected) |
||||
{ |
||||
CtrlSpace(new string[0], prog, expected); |
||||
} |
||||
|
||||
void CtrlSpace(string[] unExpected, string prog, params string[] expected) |
||||
{ |
||||
Register(prog); |
||||
int line, column; |
||||
GetPos(prog, "/*mark*/", out line, out column); |
||||
BooResolver r = new BooResolver(); |
||||
System.Collections.ArrayList ar; |
||||
ar = r.CtrlSpace(line, column, fileName, prog, ExpressionContext.Default); |
||||
foreach (string e in unExpected) { |
||||
foreach (object o in ar) { |
||||
if (e.Equals(o)) |
||||
Assert.Fail("Didn't expect " + e); |
||||
if (o is IMember && (o as IMember).Name == e) { |
||||
Assert.Fail("Didn't expect " + e); |
||||
} |
||||
if (o is IClass && (o as IClass).Name == e) { |
||||
Assert.Fail("Didn't expect " + e); |
||||
} |
||||
} |
||||
} |
||||
foreach (string e in expected) { |
||||
bool ok = false; |
||||
foreach (object o in ar) { |
||||
if (e.Equals(o)) { |
||||
if (ok) Assert.Fail("double entry " + e); |
||||
ok = true; |
||||
} |
||||
if (o is IMember && (o as IMember).Name == e) { |
||||
if (ok) Assert.Fail("double entry " + e); |
||||
ok = true; |
||||
} |
||||
if (o is IClass && (o as IClass).Name == e) { |
||||
if (ok) Assert.Fail("double entry " + e); |
||||
ok = true; |
||||
} |
||||
} |
||||
if (!ok) |
||||
Assert.Fail("Expected " + e); |
||||
} |
||||
} |
||||
|
||||
[Test] |
||||
public void CtrlSpaceScopeExtension() |
||||
{ |
||||
string prog = |
||||
"def Foo():\n" + |
||||
"\tbar = def():\n" + |
||||
"\t\tx = 0\n" + |
||||
"\t\t/*mark*/\n"; |
||||
CtrlSpace(prog, "bar", "x"); |
||||
} |
||||
|
||||
[Test] |
||||
public void DoubleEntryTest() |
||||
{ |
||||
string prog = |
||||
"class MyClass:\n" + |
||||
"\t_myInt = 0\n" + |
||||
"\tdef Foo():\n" + |
||||
"\t\t_myInt = 5\n" + |
||||
"\t\t/*mark*/\n"; |
||||
CtrlSpace(prog, "_myInt"); |
||||
} |
||||
|
||||
[Test] |
||||
public void LoopInClosureTest() |
||||
{ |
||||
string prog = |
||||
"def Foo():\n" + |
||||
"\tfor i in range(5):\n" + |
||||
"\t\tbar = def():\n" + |
||||
"\t\t\tx = 0\n" + |
||||
"\t\t\t/*mark*/\n" + |
||||
"\t\t\tprint x"; |
||||
CtrlSpace(prog, "x", "bar", "i"); |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue