From 079ea39f74c29fdee5a209f387d50e19880ffcf8 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sat, 4 Nov 2017 20:22:59 -0500 Subject: [PATCH] tests: Ensure region highlight is unset if NONE is expected --- tests/test-highlighting.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index ed7dff9..0c1d843 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -135,12 +135,16 @@ run_test_internal() { integer start=$highlight_zone[1] end=$highlight_zone[2] # Escape # as ♯ since the former is illegal in the 'description' part of TAP output local desc="[$start,$end] «${BUFFER[$start,$end]//'#'/♯}»" - # Match the emptiness of observed_result if no highlighting is expected - [[ $highlight_zone[3] == NONE ]] && highlight_zone[3]= (( $+highlight_zone[4] )) && todo="# TODO $highlight_zone[4]" for j in {$start..$end}; do - if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then - print -r -- "not ok $i - $desc - expected ${(qqq)highlight_zone[3]}, observed ${(qqq)observed_result[$j]}. $todo" + if + if [[ $highlight_zone[3] == NONE ]]; then + (( $+observed_result[$j] )) + else + [[ "$observed_result[$j]" != "$highlight_zone[3]" ]] + fi + then + print -r -- "not ok $i - $desc - expected ${(qqq)highlight_zone[3]}, observed ${(qqq)observed_result[$j]-NONE}. $todo" continue 2 fi done