Skip to content

Commit

Permalink
First test
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Feb 5, 2017
1 parent 1e26600 commit 40c3524
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 6 deletions.
23 changes: 23 additions & 0 deletions XSVim.Tests/DeleteTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace XSVim.Tests

open XSVim
open NUnit.Framework

[<TestFixture>]
module ``Delete tests`` =
[<Test>]
let ``dd test``() =
//TODO - caret finishes in wrong position
let source =
@"aaaaaa
bb$bbbb
cccccc
dddddd
eeeeee";

let expected =
@"aaaaaa
dddddd
eeeeee";
//Assert.False true
test source "Vjd" expected ""
17 changes: 17 additions & 0 deletions XSVim.Tests/Properties/AddinInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace XSVim.Tests

open System
open Mono.Addins
open Mono.Addins.Description

[<assembly:Addin (
"XSVim.Tests",
Namespace = "XSVim.Tests",
Version = "1.0"
)>]

[<assembly:AddinName ("XSVim.Tests")>]
[<assembly:AddinCategory ("IDE extensions")>]
[<assembly:AddinDescription ("XSVim.Tests")>]
[<assembly:AddinAuthor ("jason")>]
()
20 changes: 20 additions & 0 deletions XSVim.Tests/Properties/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace XSVim.Tests
open System.Reflection
open System.Runtime.CompilerServices

[<assembly: AssemblyTitle("XSVim.Tests")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("")>]
[<assembly: AssemblyCopyright("(c) Jason Imison")>]
[<assembly: AssemblyTrademark("")>]

// The assembly version has the format {Major}.{Minor}.{Build}.{Revision}

[<assembly: AssemblyVersion("1.0.0.0")>]

//[<assembly: AssemblyDelaySign(false)>]
//[<assembly: AssemblyKeyFile("")>]

()
5 changes: 5 additions & 0 deletions XSVim.Tests/Properties/Manifest.addin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionModel>
<Runtime>
</Runtime>
</ExtensionModel>
27 changes: 27 additions & 0 deletions XSVim.Tests/TestHelpers.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace XSVim.Tests

open System
open System.Text
open Mono.TextEditor
open MonoDevelop.Ide.Editor.Extension
open NUnit.Framework
open XSVim

[<AutoOpen>]
module TestHelpers =
let test (source:string) (keys:string) expected expectedMode =
let editor = new TextEditorData()
let caret = source.IndexOf "$"
editor.Text <- source.Replace("$", "")
editor.Caret.Offset <- caret
editor.Caret.UpdateCaretOffset()
let plugin = new XSVim()
let state = { keys=[]; mode=NormalMode; visualStartOffset=0; findCharCommand=None; lastAction=[] }
let newState =
keys |> Seq.fold(fun state c ->
let descriptor = KeyDescriptor.FromGtk(Gdk.Key.a (* important? *), c, Gdk.ModifierType.None)
let newState, handledKeyPress = Vim.handleKeyPress state descriptor editor
newState) state

Assert.AreEqual(expected, editor.Text)

65 changes: 65 additions & 0 deletions XSVim.Tests/XSVim.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3C522649-67F6-4F65-9CC9-D5847768FE68}</ProjectGuid>
<ProjectTypeGuids>{86F6BF2A-E449-4B3E-813B-9ACC37E5545F};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>XSVim.Tests</RootNamespace>
<AssemblyName>XSVim.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TestRunnerCommand>..\..\monodevelop\main\build\bin\mdtool.exe</TestRunnerCommand>
<TestRunnerArgs>run-md-tests</TestRunnerArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget></PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<GenerateTailCalls>true</GenerateTailCalls>
<PlatformTarget></PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0' OR '$(VisualStudioVersion)' == '11.0'">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.fs" />
<Compile Include="Properties\AddinInfo.fs" />
<Compile Include="TestHelpers.fs" />
<Compile Include="DeleteTests.fs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Manifest.addin.xml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XSVim\XSVim.fsproj">
<Project>{9DB313D4-4CD1-455F-846F-42CD234DE626}</Project>
<Name>XSVim</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="GuiUnit">
<HintPath>..\..\monodevelop\main\build\tests\GuiUnit.exe</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<AddinReference Include="MonoDevelop.SourceEditor2" />
</ItemGroup>
<Import Project="$(FSharpTargetsPath)" />
<Import Project="..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets" Condition="Exists('..\packages\MonoDevelop.Addins.0.3.3\build\net40\MonoDevelop.Addins.targets')" />
</Project>
4 changes: 4 additions & 0 deletions XSVim.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MonoDevelop.Addins" version="0.3.3" targetFramework="net45" />
</packages>
6 changes: 6 additions & 0 deletions XSVim.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "XSVim", "XSVim\XSVim.fsproj", "{9DB313D4-4CD1-455F-846F-42CD234DE626}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "XSVim.Tests", "XSVim.Tests\XSVim.Tests.fsproj", "{3C522649-67F6-4F65-9CC9-D5847768FE68}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -13,5 +15,9 @@ Global
{9DB313D4-4CD1-455F-846F-42CD234DE626}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DB313D4-4CD1-455F-846F-42CD234DE626}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DB313D4-4CD1-455F-846F-42CD234DE626}.Release|Any CPU.Build.0 = Release|Any CPU
{3C522649-67F6-4F65-9CC9-D5847768FE68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C522649-67F6-4F65-9CC9-D5847768FE68}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C522649-67F6-4F65-9CC9-D5847768FE68}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C522649-67F6-4F65-9CC9-D5847768FE68}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
10 changes: 4 additions & 6 deletions XSVim/XSVim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,7 @@ module VimHelpers =
| _ -> editor.Caret.Offset, editor.Caret.Offset
| _ -> editor.Caret.Offset, editor.Caret.Offset

type XSVim() =
inherit TextEditorExtension()

module Vim =
let (|VisualModes|_|) mode =
match mode with
| VisualMode | VisualLineMode | VisualBlockMode -> Some VisualModes
Expand Down Expand Up @@ -322,8 +320,6 @@ type XSVim() =
editor.SetSelection(startLine.Offset, endLine.EndOffsetIncludingDelimiter)
| _ -> editor.SetSelection(start, finish)



let runCommand vimState editor command =
let delete start finish =
let finish =
Expand Down Expand Up @@ -647,6 +643,8 @@ type XSVim() =

performActions action { newState with lastAction = action } false

type XSVim() =
inherit TextEditorExtension()
let mutable vimState = { keys=[]; mode=NormalMode; visualStartOffset=0; findCharCommand=None; lastAction=[] }

let getEditorData (this:XSVim) = this.Editor.GetContent<ITextEditorDataProvider>().GetTextEditorData()
Expand All @@ -659,7 +657,7 @@ type XSVim() =
let editorData = getEditorData x
let oldState = vimState

let newState, handledKeyPress = handleKeyPress vimState descriptor editorData
let newState, handledKeyPress = Vim.handleKeyPress vimState descriptor editorData
//LoggingService.LogDebug (sprintf "%A %A" newState handledKeyPress)
vimState <- newState
match oldState.mode with
Expand Down

0 comments on commit 40c3524

Please sign in to comment.