minor: tests: Tighten up local variable scope.
This commit is contained in:
parent
21207c336a
commit
70b5687d66
@ -62,7 +62,6 @@ ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
|||||||
# Runs a highlighting test
|
# Runs a highlighting test
|
||||||
# $1: data file
|
# $1: data file
|
||||||
run_test_internal() {
|
run_test_internal() {
|
||||||
local -a highlight_zone
|
|
||||||
|
|
||||||
local tests_tempdir="$1"; shift
|
local tests_tempdir="$1"; shift
|
||||||
local srcdir="$PWD"
|
local srcdir="$PWD"
|
||||||
@ -87,7 +86,7 @@ run_test_internal() {
|
|||||||
# observed highlighting.
|
# observed highlighting.
|
||||||
local -A observed_result
|
local -A observed_result
|
||||||
for ((i=1; i<=${#region_highlight}; i++)); do
|
for ((i=1; i<=${#region_highlight}; i++)); do
|
||||||
highlight_zone=${(z)region_highlight[$i]}
|
local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} )
|
||||||
integer start=$highlight_zone[1] end=$highlight_zone[2]
|
integer start=$highlight_zone[1] end=$highlight_zone[2]
|
||||||
if (( start < end )) # region_highlight ranges are half-open
|
if (( start < end )) # region_highlight ranges are half-open
|
||||||
then
|
then
|
||||||
@ -99,13 +98,15 @@ run_test_internal() {
|
|||||||
else
|
else
|
||||||
# noop range; ignore.
|
# noop range; ignore.
|
||||||
fi
|
fi
|
||||||
|
unset start end
|
||||||
|
unset highlight_zone
|
||||||
done
|
done
|
||||||
|
|
||||||
# Then we compare the observed result with the expected one.
|
# Then we compare the observed result with the expected one.
|
||||||
echo "1..${#expected_region_highlight}"
|
echo "1..${#expected_region_highlight}"
|
||||||
for ((i=1; i<=${#expected_region_highlight}; i++)); do
|
for ((i=1; i<=${#expected_region_highlight}; i++)); do
|
||||||
|
local -a highlight_zone; highlight_zone=( ${(z)expected_region_highlight[$i]} )
|
||||||
local todo=
|
local todo=
|
||||||
highlight_zone=${(z)expected_region_highlight[$i]}
|
|
||||||
[[ $highlight_zone[3] == NONE ]] && highlight_zone[3]=
|
[[ $highlight_zone[3] == NONE ]] && highlight_zone[3]=
|
||||||
[[ -n "$highlight_zone[4]" ]] && todo=" # TODO $highlight_zone[4]"
|
[[ -n "$highlight_zone[4]" ]] && todo=" # TODO $highlight_zone[4]"
|
||||||
for j in {$highlight_zone[1]..$highlight_zone[2]}; do
|
for j in {$highlight_zone[1]..$highlight_zone[2]}; do
|
||||||
@ -116,6 +117,8 @@ run_test_internal() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "ok $i$todo"
|
echo "ok $i$todo"
|
||||||
|
unset todo
|
||||||
|
unset highlight_zone
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user