-
Notifications
You must be signed in to change notification settings - Fork 12
/
ExModeTests.fs
100 lines (79 loc) · 2.75 KB
/
ExModeTests.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
namespace XSVim.Tests
open NUnit.Framework
open XSVim
open System.Runtime.CompilerServices
open System.Threading.Tasks
[<TestFixture>]
module ``Ex mode tests`` =
[<SetUp;AsyncStateMachine(typeof<Task>)>]
let ``run before tests``() =
FixtureSetup.initialiseMonoDevelop()
[<Test>]
let ``/ searches for word``() =
assertText "ab$c abc" "/abc<ret>" "abc a$bc"
[<Test>]
let ``/ is case insensitive``() =
assertText "ab$c ABC" "/abc<ret>" "abc A$BC"
[<Test>]
let ``/ is case sensitive``() =
assertText "ab$c ABC Abc" "/Abc<ret>" "abc ABC A$bc"
[<Test>]
let ``deletes to search term``() =
assertText "ab$c ABC Abc 123" "d/123<ret>" "a1$23"
[<Test>]
let ``n searches for next word``() =
assertText "ab$c abc abc" "/abc<ret>n" "abc abc a$bc"
[<Test>]
let ``n wraps to start``() =
assertText "ab$c abc abc" "/abc<ret>nn" "a$bc abc abc"
[<Test>]
let ``N searches for previous word``() =
assertText "ab$c abc abc" "/abc<ret>N" "a$bc abc abc"
[<Test>]
let ``n searches for previous word after ?``() =
assertText "abc abc a$bc" "?abc<ret>n" "a$bc abc abc"
[<Test>]
let ``? searches for word backwards``() =
assertText "abc abc a$bc" "?abc<ret>" "abc a$bc abc"
[<Test>]
let ``:2 jumps to line 2``() =
assertText "l$ine1\nline2" ":2<ret>" "line1\nl$ine2"
[<Test>]
let ``Backspacing ex mode returns to normal mode``() =
let _, state, _ = test "abc abc a$bc" "/a<bs><bs>"
state.mode |> should equal NormalMode
[<Test>]
let ``<esc> returns to normal mode``() =
let _, state, _ = test "abc abc a$bc" "/<esc>"
state.mode |> should equal NormalMode
[<Test>]
let ``<C-c> returns to normal mode``() =
let _, state, _ = test "abc abc a$bc" "/<C-c>"
state.mode |> should equal NormalMode
[<Test>]
let ``<C-[> returns to normal mode``() =
let _, state, _ = test "abc abc a$bc" "/<C-[>"
state.mode |> should equal NormalMode
[<Test>]
let ``Displays could not parse message``() =
let _, state, _ = test "a$bc" ":garbage<ret>"
state.statusMessage.Value |> should equal "Could not parse :garbage"
[<Test>]
let ``Could not parse message is reset``() =
let _, state, _ = test "a$bc" ":garbage<ret>l"
state.statusMessage |> should equal None
[<Test>]
let ``Deletes lines 2 to 4``() =
assertText
"""11111
22222
33333
44444
55555$"""
":2,4d<ret>"
"""11111
5$5555"""
[<Test>]
let ``Switching to substitute command mode with a selection``() =
let _, state, _ = test "a$bc" "v:"
state.statusMessage |> should equal (Some ":'<,'>")