1
1
local load_fixture = require " tests.load_fixture"
2
2
local tw = require ' treewalker'
3
- local helpers = require ' tests.treewalker.helpers'
3
+ local h = require ' tests.treewalker.helpers'
4
4
5
5
describe (" Movement in a regular lua file: " , function ()
6
6
before_each (function ()
@@ -10,80 +10,80 @@ describe("Movement in a regular lua file: ", function()
10
10
it (" moves up and down at the same pace" , function ()
11
11
vim .fn .cursor (1 , 1 ) -- Reset cursor
12
12
tw .move_down ()
13
- helpers .assert_cursor_at (3 , 1 )
13
+ h .assert_cursor_at (3 , 1 )
14
14
tw .move_down ()
15
- helpers .assert_cursor_at (5 , 1 )
15
+ h .assert_cursor_at (5 , 1 )
16
16
tw .move_down ()
17
- helpers .assert_cursor_at (10 , 1 )
17
+ h .assert_cursor_at (10 , 1 )
18
18
tw .move_down ()
19
- helpers .assert_cursor_at (21 , 1 )
19
+ h .assert_cursor_at (21 , 1 )
20
20
tw .move_up ()
21
- helpers .assert_cursor_at (10 , 1 )
21
+ h .assert_cursor_at (10 , 1 )
22
22
tw .move_up ()
23
- helpers .assert_cursor_at (5 , 1 )
23
+ h .assert_cursor_at (5 , 1 )
24
24
tw .move_up ()
25
- helpers .assert_cursor_at (3 , 1 )
25
+ h .assert_cursor_at (3 , 1 )
26
26
tw .move_up ()
27
- helpers .assert_cursor_at (1 , 1 )
27
+ h .assert_cursor_at (1 , 1 )
28
28
end )
29
29
30
30
it (" doesn't consider empty lines to be outer scopes" , function ()
31
31
vim .fn .cursor (85 , 1 )
32
32
tw .move_down ()
33
- helpers .assert_cursor_at (88 , 3 , " local" )
33
+ h .assert_cursor_at (88 , 3 , " local" )
34
34
vim .fn .cursor (85 , 1 )
35
35
tw .move_up ()
36
- helpers .assert_cursor_at (84 , 3 , " end" )
36
+ h .assert_cursor_at (84 , 3 , " end" )
37
37
end )
38
38
39
39
it (" goes into functions eagerly" , function ()
40
40
vim .fn .cursor (143 , 1 ) -- In a bigger function
41
41
tw .move_in ()
42
- helpers .assert_cursor_at (144 , 3 )
42
+ h .assert_cursor_at (144 , 3 )
43
43
tw .move_in ()
44
- helpers .assert_cursor_at (147 , 5 )
44
+ h .assert_cursor_at (147 , 5 )
45
45
tw .move_in ()
46
- helpers .assert_cursor_at (149 , 7 )
46
+ h .assert_cursor_at (149 , 7 )
47
47
end )
48
48
49
49
it (" doesn't jump into a comment" , function ()
50
50
vim .fn .cursor (177 , 1 )
51
51
tw .move_in ()
52
- helpers .assert_cursor_at (179 , 3 , " local" )
52
+ h .assert_cursor_at (179 , 3 , " local" )
53
53
end )
54
54
55
55
it (" goes out of functions" , function ()
56
56
vim .fn .cursor (149 , 7 )
57
57
tw .move_out ()
58
- helpers .assert_cursor_at (148 , 5 , " if" )
58
+ h .assert_cursor_at (148 , 5 , " if" )
59
59
tw .move_out ()
60
- helpers .assert_cursor_at (146 , 3 , " while" )
60
+ h .assert_cursor_at (146 , 3 , " while" )
61
61
tw .move_out ()
62
- helpers .assert_cursor_at (143 , 1 , " function" )
62
+ h .assert_cursor_at (143 , 1 , " function" )
63
63
end )
64
64
65
65
-- aka doesn't error
66
66
it (" is chill when down is invoked from empty last line" , function ()
67
- helpers .feed_keys (' G' )
67
+ h .feed_keys (' G' )
68
68
tw .move_down ()
69
69
end )
70
70
71
71
it (" moves up from inside a function" , function ()
72
72
vim .fn .cursor (21 , 16 ) -- |is_jump_target
73
73
tw .move_up ()
74
- helpers .assert_cursor_at (10 , 1 , " local TARGET_DESCENDANT_TYPES" )
74
+ h .assert_cursor_at (10 , 1 , " local TARGET_DESCENDANT_TYPES" )
75
75
end )
76
76
77
77
it (" moves down from inside a function" , function ()
78
78
vim .fn .cursor (21 , 16 ) -- |is_jump_target
79
79
tw .move_down ()
80
- helpers .assert_cursor_at (30 , 1 , " local function is_descendant_jump_target" )
80
+ h .assert_cursor_at (30 , 1 , " local function is_descendant_jump_target" )
81
81
end )
82
82
83
83
it (" moves to true outer node when invoked from inside a line" , function ()
84
84
vim .fn .cursor (22 , 28 ) -- |NON_
85
85
tw .move_out ()
86
- helpers .assert_cursor_at (21 , 1 )
86
+ h .assert_cursor_at (21 , 1 )
87
87
end )
88
88
end )
89
89
@@ -98,28 +98,28 @@ describe("Movement in a lua spec file: ", function()
98
98
for _ = 1 , 6 do
99
99
tw .move_down ()
100
100
end
101
- helpers .assert_cursor_at (17 , 1 , " describe" )
101
+ h .assert_cursor_at (17 , 1 , " describe" )
102
102
end
103
103
104
104
-- go to first load_buf
105
105
local function go_to_load_buf ()
106
106
go_to_describe ()
107
107
tw .move_in (); tw .move_in ()
108
- helpers .assert_cursor_at (19 , 5 , " load_buf" )
108
+ h .assert_cursor_at (19 , 5 , " load_buf" )
109
109
end
110
110
111
111
it (" moves up and down at the same pace" , function ()
112
112
go_to_load_buf ()
113
113
tw .move_down (); tw .move_down ()
114
- helpers .assert_cursor_at (41 , 5 , " it" )
114
+ h .assert_cursor_at (41 , 5 , " it" )
115
115
tw .move_up (); tw .move_up ()
116
- helpers .assert_cursor_at (19 , 5 , " load_buf" )
116
+ h .assert_cursor_at (19 , 5 , " load_buf" )
117
117
end )
118
118
119
119
it (" always moves down at least one line" , function ()
120
120
go_to_load_buf ()
121
121
tw .move_down ()
122
- helpers .assert_cursor_at (21 , 5 , " it" )
122
+ h .assert_cursor_at (21 , 5 , " it" )
123
123
end )
124
124
end )
125
125
@@ -131,7 +131,7 @@ describe("Movement in a haskell file: ", function()
131
131
it (" moves out of a nested node" , function ()
132
132
vim .fn .cursor (22 , 3 )
133
133
tw .move_out ()
134
- helpers .assert_cursor_at (19 , 1 , " |randomList" )
134
+ h .assert_cursor_at (19 , 1 , " |randomList" )
135
135
end )
136
136
end )
137
137
@@ -143,12 +143,12 @@ describe("Movement in a python file: ", function()
143
143
it (" You can get into the body of a function with multiline signature" , function ()
144
144
vim .fn .cursor (131 , 3 ) -- de|f
145
145
tw .move_in ()
146
- helpers .assert_cursor_at (132 , 5 )
146
+ h .assert_cursor_at (132 , 5 )
147
147
tw .move_down ()
148
- helpers .assert_cursor_at (133 , 5 )
148
+ h .assert_cursor_at (133 , 5 )
149
149
tw .move_down ()
150
- helpers .assert_cursor_at (134 , 5 )
150
+ h .assert_cursor_at (134 , 5 )
151
151
tw .move_down ()
152
- helpers .assert_cursor_at (136 , 5 , " |print" )
152
+ h .assert_cursor_at (136 , 5 , " |print" )
153
153
end )
154
154
end )
0 commit comments