mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-12-04 21:56:45 +01:00
test harness: Fix off-by-one discrepancy between observed and expected.
Fixes issue #195.
This commit is contained in:
parent
6d93ea07fd
commit
c46b8d169e
13 changed files with 40 additions and 30 deletions
|
|
@ -5,6 +5,13 @@ Utility scripts for testing zsh-syntax-highlighting highlighters.
|
|||
|
||||
The tests expect the highlighter directory to contain a `test-data` directory with test data files. See the [main highlighter](../highlighters/main/test-data) for examples.
|
||||
|
||||
Each test should define the array parameter `$expected_region_highlight`.
|
||||
The value of that parameter is a list of `"$i $j $style"` strings.
|
||||
Each string specifies the highlighting that `$BUFFER[$i,$j]` should have;
|
||||
that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints.
|
||||
|
||||
_Note_: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently.
|
||||
|
||||
|
||||
highlighting test
|
||||
-----------------
|
||||
|
|
|
|||
|
|
@ -84,7 +84,10 @@ for data_file in ${0:h:h}/highlighters/$1/test-data/*; do
|
|||
observed_result=()
|
||||
for i in {1..${#region_highlight}}; do
|
||||
highlight_zone=${(z)region_highlight[$i]}
|
||||
for j in {$highlight_zone[1]..$highlight_zone[2]}; do
|
||||
integer start=$highlight_zone[1] end=$highlight_zone[2]
|
||||
(( --end )) # region_highlight ranges are half-open
|
||||
(( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed
|
||||
for j in {$start..$end}; do
|
||||
observed_result[$j]=$highlight_zone[3]
|
||||
done
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue