Skip to content

Commit 39e5e7f

Browse files
gasparchkassio
authored andcommitted
Highlight ExUnit assert/refute functions and macros (#225)
* highlight ExUnit assert/refute functions and macros * add syntax highlight tests for ExUnit macro/functions support
1 parent 5552505 commit 39e5e7f

File tree

2 files changed

+123
-1
lines changed

2 files changed

+123
-1
lines changed

spec/syntax/exunit_spec.rb

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,123 @@
4444
end
4545
EOF
4646
end
47+
48+
it 'on_exit macro' do
49+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitMacro', 'on_exit')
50+
setup_all do
51+
IO.puts "hi mom"
52+
on_exit fn() ->
53+
do_something
54+
end
55+
end
56+
57+
test 'that stuff works' do
58+
assert true
59+
end
60+
EOF
61+
end
62+
63+
it 'assert' do
64+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'assert')
65+
test 'that stuff works' do
66+
assert true
67+
end
68+
EOF
69+
end
70+
71+
it 'assert_in_delta' do
72+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'assert_in_delta')
73+
test 'that stuff works' do
74+
assert_in_delta true
75+
end
76+
EOF
77+
end
78+
79+
it 'assert_raise' do
80+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'assert_raise')
81+
test 'that stuff works' do
82+
assert_raise true
83+
end
84+
EOF
85+
end
86+
87+
it 'assert_receive' do
88+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'assert_receive')
89+
test 'that stuff works' do
90+
assert_receive true
91+
end
92+
EOF
93+
end
94+
95+
it 'assert_received' do
96+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'assert_received')
97+
test 'that stuff works' do
98+
assert_received true
99+
end
100+
EOF
101+
end
102+
103+
it 'catch_error' do
104+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'catch_error')
105+
test 'that stuff works' do
106+
catch_error true
107+
end
108+
EOF
109+
end
110+
111+
it 'catch_exit' do
112+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'catch_exit')
113+
test 'that stuff works' do
114+
catch_exit true
115+
end
116+
EOF
117+
end
118+
119+
it 'catch_throw' do
120+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'catch_throw')
121+
test 'that stuff works' do
122+
catch_throw true
123+
end
124+
EOF
125+
end
126+
127+
it 'flunk' do
128+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'flunk')
129+
test 'that stuff works' do
130+
flunk true
131+
end
132+
EOF
133+
end
134+
135+
it 'refute' do
136+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'refute')
137+
test 'that stuff works' do
138+
refute true
139+
end
140+
EOF
141+
end
142+
143+
it 'refute_in_delta' do
144+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'refute_in_delta')
145+
test 'that stuff works' do
146+
refute_in_delta true
147+
end
148+
EOF
149+
end
150+
151+
it 'refute_receive' do
152+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'refute_receive')
153+
test 'that stuff works' do
154+
refute_receive true
155+
end
156+
EOF
157+
end
158+
159+
it 'refute_received' do
160+
expect(<<~EOF).to include_elixir_syntax('elixirExUnitAssert', 'refute_received')
161+
test 'that stuff works' do
162+
refute_received true
163+
end
164+
EOF
165+
end
47166
end

syntax/elixir.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained con
165165
syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl
166166

167167
" ExUnit
168-
syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\)\>"
168+
syn match elixirExUnitMacro "\(^\s*\)\@<=\<\(test\|describe\|setup\|setup_all\|on_exit\)\>"
169+
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(assert\|assert_in_delta\|assert_raise\|assert_receive\|assert_received\|catch_error\)\>"
170+
syn match elixirExUnitAssert "\(^\s*\)\@<=\<\(catch_exit\|catch_throw\|flunk\|refute\|refute_in_delta\|refute_receive\|refute_received\)\>"
169171

170172
hi def link elixirBlockInline Keyword
171173
hi def link elixirBlockDefinition Keyword
@@ -191,6 +193,7 @@ hi def link elixirInclude Include
191193
hi def link elixirComment Comment
192194
hi def link elixirTodo Todo
193195
hi def link elixirKeyword Keyword
196+
hi def link elixirExUnitAssert Keyword
194197
hi def link elixirOperator Operator
195198
hi def link elixirAtom Constant
196199
hi def link elixirPseudoVariable Constant

0 commit comments

Comments
 (0)