Skip to content

Commit 7977111

Browse files
committed
Add basic tests
1 parent 0dd51c0 commit 7977111

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/runtests.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
using JuliaSyntaxHighlighting: highlight, highlight!
4+
using Test
5+
6+
# We could go to the effort of testing each individual highlight face,
7+
# however here we're aiming for the much lower bar of ensuring that
8+
# `highlight` consistently returns a reasonable result.
9+
# This also avoids testing as much of the particulars of JuliaSyntax.
10+
11+
sum1to8_highlighted = Base.AnnotatedString("sum(1:8)", [
12+
(1:3, :face => :julia_funcall),
13+
(4:4, :face => :julia_rainbow_paren_1),
14+
(5:5, :face => :julia_number),
15+
(6:6, :face => :julia_operator),
16+
(7:7, :face => :julia_number),
17+
(8:8, :face => :julia_rainbow_paren_1)
18+
])
19+
20+
@test highlight("sum(1:8)") ==sum1to8_highlighted
21+
@test highlight(IOBuffer("sum(1:8)")) ==sum1to8_highlighted
22+
@test highlight(IOContext(IOBuffer("sum(1:8)"))) ==sum1to8_highlighted
23+
24+
astr_sum1to8 = Base.AnnotatedString("sum(1:8)")
25+
@test highlight!(astr_sum1to8) == sum1to8_highlighted
26+
@test astr_sum1to8 == sum1to8_highlighted

0 commit comments

Comments
 (0)