Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2239 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
7 changed files with 91 additions and 70 deletions
@ -1,60 +0,0 @@ |
|||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||||
<PropertyGroup> |
|
||||||
<OutputType>Library</OutputType> |
|
||||||
<RootNamespace>CSharpBinding.Tests</RootNamespace> |
|
||||||
<AssemblyName>CSharpBinding.Tests</AssemblyName> |
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|
||||||
<ProjectGuid>{4D0DFCB0-F6FB-469D-AA6F-C7F1D5FD5DE7}</ProjectGuid> |
|
||||||
<OutputPath>..\..\..\..\..\bin\UnitTests\</OutputPath> |
|
||||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
|
||||||
<NoStdLib>False</NoStdLib> |
|
||||||
<RegisterForComInterop>False</RegisterForComInterop> |
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget> |
|
||||||
<WarningLevel>4</WarningLevel> |
|
||||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|
||||||
<Optimize>False</Optimize> |
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|
||||||
<DebugSymbols>true</DebugSymbols> |
|
||||||
<DebugType>Full</DebugType> |
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
|
||||||
</PropertyGroup> |
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|
||||||
<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="ExpressionFinder.cs" /> |
|
||||||
</ItemGroup> |
|
||||||
<ItemGroup> |
|
||||||
<ProjectReference Include="..\Project\CSharpBinding.csproj"> |
|
||||||
<Project>{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}</Project> |
|
||||||
<Name>CSharpBinding</Name> |
|
||||||
<Private>True</Private> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
|
||||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop</Name> |
|
||||||
<Private>True</Private> |
|
||||||
</ProjectReference> |
|
||||||
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
|
||||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
|
||||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
|
||||||
</ProjectReference> |
|
||||||
</ItemGroup> |
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
|
||||||
</Project> |
|
@ -0,0 +1,78 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Reflection; |
||||||
|
using System.Collections.Generic; |
||||||
|
using NUnit.Framework; |
||||||
|
using ICSharpCode.SharpDevelop; |
||||||
|
using ICSharpCode.SharpDevelop.Dom; |
||||||
|
using ICSharpCode.SharpDevelop.Dom.VBNet; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class VBExpressionFinderTests |
||||||
|
{ |
||||||
|
const string program1 = @"
|
||||||
|
Class MainClass ' a comment |
||||||
|
Dim under_score_field As Integer |
||||||
|
Sub SomeMethod() |
||||||
|
simple += 1 |
||||||
|
For Each loopVarName In collection |
||||||
|
Next |
||||||
|
End Sub |
||||||
|
End Class |
||||||
|
";
|
||||||
|
|
||||||
|
VBExpressionFinder ef; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
HostCallback.GetParseInformation = ParserService.GetParseInformation; |
||||||
|
HostCallback.GetCurrentProjectContent = delegate { |
||||||
|
return ParserService.CurrentProjectContent; |
||||||
|
}; |
||||||
|
|
||||||
|
ef = new VBExpressionFinder(); |
||||||
|
} |
||||||
|
|
||||||
|
void FindFull(string program, string location, string expectedExpression, ExpressionContext expectedContext) |
||||||
|
{ |
||||||
|
int pos = program.IndexOf(location); |
||||||
|
if (pos < 0) Assert.Fail("location not found in program"); |
||||||
|
ExpressionResult er = ef.FindFullExpression(program, pos); |
||||||
|
Assert.AreEqual(expectedExpression, er.Expression); |
||||||
|
Assert.AreEqual(expectedContext.ToString(), er.Context.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Simple() |
||||||
|
{ |
||||||
|
FindFull(program1, "mple += 1", "simple", ExpressionContext.Default); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void SimpleBeginningOfExpression() |
||||||
|
{ |
||||||
|
FindFull(program1, "simple += 1", "simple", ExpressionContext.Default); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Underscore() |
||||||
|
{ |
||||||
|
FindFull(program1, "der_score_field", "under_score_field", ExpressionContext.Default); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IdentifierBeforeKeyword() |
||||||
|
{ |
||||||
|
FindFull(program1, "arName", "loopVarName", ExpressionContext.Default); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue