Skip to content

Commit da09408

Browse files
authored
Add syntax test (#71)
* add tests * update ci * update ci * update CONTRIBUTING.md * more tests * more tests * update * rm ppa repo * use action-setup-vim
1 parent 8128c04 commit da09408

File tree

6 files changed

+478
-5
lines changed

6 files changed

+478
-5
lines changed

.github/workflows/pull-request.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ jobs:
66
name: Test
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Install packages
10-
run: |
11-
sudo add-apt-repository ppa:neovim-ppa/stable
12-
sudo apt update
13-
sudo apt install neovim
9+
- uses: rhysd/action-setup-vim@v1
10+
with:
11+
neovim: true
1412
- uses: actions/checkout@v1
1513
- uses: actions/setup-node@v1
1614
with:
@@ -22,3 +20,5 @@ jobs:
2220
nvim --version
2321
vim --version
2422
make test
23+
- name: Test syntax
24+
run: make test-syntax

CONTRIBUTING.md

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Clone the repo
66
- `npm install` dependencies
77
- `make test` to run the tests
8+
- `make test-syntax`, require Neovim >= 0.9.0
89

910
**Working within VIM**
1011

@@ -21,6 +22,20 @@ Plug ~/Projects/vim-rescript
2122
**Integration Specs:**
2223
For all the informal specs about editor integration & the ReScript platform, check out the [CONTRIBUTING](https://github.com/rescript-lang/rescript-vscode/blob/master/CONTRIBUTING.md) file of the rescript-vscode reference implementation.
2324

25+
### Syntax Tests
26+
27+
Syntax tests require Neovim >= 0.9.0
28+
29+
#### Adding new tests
30+
31+
- Create or edit a file at `test/syntax/` directory.
32+
- Write some code and add a comment in the following format: `//^` below the code. The `^` indicates the capture location. Example:
33+
```rescript
34+
let a = true
35+
//^
36+
```
37+
- Run `make test-syntax`
38+
2439
### Use custom rescript-editor-support.exe
2540

2641
> Note: Don't do this as a ReScript user. This is only intended for extension development purposes only.

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ export INMAKE
77

88
test:
99
@$(MYVIM) -u ./test/test_all.vim
10+
11+
test-syntax:
12+
nvim -l test/test-syntax.lua
13+
git diff --name-only --exit-code -- 'test/syntax/expected/*.res.txt'
+271
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
{ {
2+
col = 1,
3+
row = 0,
4+
syntax = { {
5+
hl_group = "resArrowPipe",
6+
hl_group_link = "Statement"
7+
} }
8+
}, {
9+
col = 1,
10+
row = 3,
11+
syntax = {}
12+
}, {
13+
col = 1,
14+
row = 6,
15+
syntax = { {
16+
hl_group = "resAttribute",
17+
hl_group_link = "PreProc"
18+
} }
19+
}, {
20+
col = 9,
21+
row = 8,
22+
syntax = {}
23+
}, {
24+
col = 1,
25+
row = 11,
26+
syntax = { {
27+
hl_group = "resKeyword",
28+
hl_group_link = "Statement"
29+
} }
30+
}, {
31+
col = 7,
32+
row = 14,
33+
syntax = {}
34+
}, {
35+
col = 9,
36+
row = 17,
37+
syntax = { {
38+
hl_group = "resBoolean",
39+
hl_group_link = "Constant"
40+
} }
41+
}, {
42+
col = 9,
43+
row = 19,
44+
syntax = { {
45+
hl_group = "resBoolean",
46+
hl_group_link = "Constant"
47+
} }
48+
}, {
49+
col = 11,
50+
row = 22,
51+
syntax = { {
52+
hl_group = "resString",
53+
hl_group_link = "Constant"
54+
} }
55+
}, {
56+
col = 19,
57+
row = 24,
58+
syntax = { {
59+
hl_group = "resString",
60+
hl_group_link = "Constant"
61+
} }
62+
}, {
63+
col = 8,
64+
row = 26,
65+
syntax = { {
66+
hl_group = "resChar",
67+
hl_group_link = "Constant"
68+
} }
69+
}, {
70+
col = 11,
71+
row = 29,
72+
syntax = { {
73+
hl_group = "resString",
74+
hl_group_link = "Constant"
75+
} }
76+
}, {
77+
col = 8,
78+
row = 32,
79+
syntax = {}
80+
}, {
81+
col = 12,
82+
row = 34,
83+
syntax = {}
84+
}, {
85+
col = 12,
86+
row = 37,
87+
syntax = {}
88+
}, {
89+
col = 7,
90+
row = 40,
91+
syntax = {}
92+
}, {
93+
col = 9,
94+
row = 43,
95+
syntax = {}
96+
}, {
97+
col = 9,
98+
row = 46,
99+
syntax = {}
100+
}, {
101+
col = 1,
102+
row = 49,
103+
syntax = { {
104+
hl_group = "resKeyword",
105+
hl_group_link = "Statement"
106+
} }
107+
}, {
108+
col = 4,
109+
row = 52,
110+
syntax = {}
111+
}, {
112+
col = 7,
113+
row = 56,
114+
syntax = { {
115+
hl_group = "resType",
116+
hl_group_link = "Type"
117+
} }
118+
}, {
119+
col = 7,
120+
row = 61,
121+
syntax = {}
122+
}, {
123+
col = 9,
124+
row = 65,
125+
syntax = { {
126+
hl_group = "resType",
127+
hl_group_link = "Type"
128+
} }
129+
}, {
130+
col = 11,
131+
row = 68,
132+
syntax = {}
133+
}, {
134+
col = 9,
135+
row = 71,
136+
syntax = { {
137+
hl_group = "resModuleOrVariant",
138+
hl_group_link = "Identifier"
139+
} }
140+
}, {
141+
col = 9,
142+
row = 74,
143+
syntax = { {
144+
hl_group = "resPolyVariant",
145+
hl_group_link = "Identifier"
146+
} }
147+
}, {
148+
col = 7,
149+
row = 77,
150+
syntax = {}
151+
}, {
152+
col = 3,
153+
row = 80,
154+
syntax = { {
155+
hl_group = "resKeyword",
156+
hl_group_link = "Statement"
157+
} }
158+
}, {
159+
col = 1,
160+
row = 85,
161+
syntax = { {
162+
hl_group = "resKeyword",
163+
hl_group_link = "Statement"
164+
} }
165+
}, {
166+
col = 2,
167+
row = 87,
168+
syntax = { {
169+
hl_group = "resModuleChain",
170+
hl_group_link = "PreProc"
171+
} }
172+
}, {
173+
col = 1,
174+
row = 91,
175+
syntax = { {
176+
hl_group = "resKeyword",
177+
hl_group_link = "Statement"
178+
} }
179+
}, {
180+
col = 1,
181+
row = 96,
182+
syntax = { {
183+
hl_group = "resKeyword",
184+
hl_group_link = "Statement"
185+
} }
186+
}, {
187+
col = 1,
188+
row = 100,
189+
syntax = { {
190+
hl_group = "resKeyword",
191+
hl_group_link = "Statement"
192+
} }
193+
}, {
194+
col = 3,
195+
row = 103,
196+
syntax = { {
197+
hl_group = "resKeyword",
198+
hl_group_link = "Statement"
199+
} }
200+
}, {
201+
col = 17,
202+
row = 105,
203+
syntax = { {
204+
hl_group = "resKeyword",
205+
hl_group_link = "Statement"
206+
} }
207+
}, {
208+
col = 1,
209+
row = 109,
210+
syntax = { {
211+
hl_group = "resKeyword",
212+
hl_group_link = "Statement"
213+
} }
214+
}, {
215+
col = 1,
216+
row = 112,
217+
syntax = { {
218+
hl_group = "resKeyword",
219+
hl_group_link = "Statement"
220+
} }
221+
}, {
222+
col = 1,
223+
row = 116,
224+
syntax = { {
225+
hl_group = "resKeyword",
226+
hl_group_link = "Statement"
227+
} }
228+
}, {
229+
col = 1,
230+
row = 118,
231+
syntax = {}
232+
}, {
233+
col = 5,
234+
row = 120,
235+
syntax = {}
236+
}, {
237+
col = 5,
238+
row = 124,
239+
syntax = { {
240+
hl_group = "resType",
241+
hl_group_link = "Type"
242+
} }
243+
}, {
244+
col = 5,
245+
row = 126,
246+
syntax = { {
247+
hl_group = "resType",
248+
hl_group_link = "Type"
249+
} }
250+
}, {
251+
col = 5,
252+
row = 128,
253+
syntax = { {
254+
hl_group = "resKeyword",
255+
hl_group_link = "Statement"
256+
} }
257+
}, {
258+
col = 4,
259+
row = 130,
260+
syntax = { {
261+
hl_group = "resType",
262+
hl_group_link = "Type"
263+
} }
264+
}, {
265+
col = 5,
266+
row = 132,
267+
syntax = { {
268+
hl_group = "resType",
269+
hl_group_link = "Type"
270+
} }
271+
} }

0 commit comments

Comments
 (0)