tests: Test ZSH_HIGHLIGHT_STYLES keys directly
Closes #287. Testing the keys directly removes the need for unused_highlight which will be removed next.
This commit is contained in:
parent
ccaf6f48a1
commit
fd061b5730
@ -50,6 +50,12 @@
|
|||||||
# Load the main script.
|
# Load the main script.
|
||||||
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
# Overwrite _zsh_highlight_add_highlight so we get the key itself instead of the style
|
||||||
|
_zsh_highlight_add_highlight()
|
||||||
|
{
|
||||||
|
region_highlight+=("$1 $2 $3")
|
||||||
|
}
|
||||||
|
|
||||||
# Activate the highlighter.
|
# Activate the highlighter.
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
||||||
|
|
||||||
@ -104,8 +110,8 @@ run_test_internal() {
|
|||||||
[[ $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
|
||||||
if [[ "$observed_result[$j]" != "$ZSH_HIGHLIGHT_STYLES[$highlight_zone[3]]" ]]; then
|
if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then
|
||||||
echo "not ok $i ${(qqq)BUFFER[$highlight_zone[1],$highlight_zone[2]]} [$highlight_zone[1],$highlight_zone[2]]: expected ${(qqq)ZSH_HIGHLIGHT_STYLES[$highlight_zone[3]]}, observed ${(qqq)observed_result[$j]}.$todo"
|
echo "not ok $i ${(qqq)BUFFER[$highlight_zone[1],$highlight_zone[2]]} [$highlight_zone[1],$highlight_zone[2]]: expected $highlight_zone[3], observed ${(qqq)observed_result[$j]}.$todo"
|
||||||
continue 2
|
continue 2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -196,9 +196,10 @@ _zsh_highlight_cursor_moved()
|
|||||||
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
|
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add a highlight defined by ZSH_HIGHLIGHT_STYLES
|
# Add a highlight defined by ZSH_HIGHLIGHT_STYLES.
|
||||||
#
|
#
|
||||||
# Should be used by all highlighters aside from 'pattern' (cf. ZSH_HIGHLIGHT_PATTERN)
|
# Should be used by all highlighters aside from 'pattern' (cf. ZSH_HIGHLIGHT_PATTERN).
|
||||||
|
# Overwritten in tests/test-highlighting.zsh when testing.
|
||||||
_zsh_highlight_add_highlight()
|
_zsh_highlight_add_highlight()
|
||||||
{
|
{
|
||||||
local -i start end
|
local -i start end
|
||||||
|
Loading…
Reference in New Issue
Block a user