From aab1b8f50f9d068e9f9662bd490039af89629339 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 17 Sep 2015 23:17:22 +0000 Subject: [PATCH] Follow-up to 547b8be30461: Fix $observed_result calculation. In region_highlight, a spec of the form 'i j foo' with i >= j should have no effect. Before this commit, however, the {$i..$j} range would happily expand to (5 4 3) if i > j were the case (e.g., i=5 and j=3). This breaks vanilla-newline.zsh; the next commit will fix that. --- tests/test-highlighting.zsh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index 2e5a20c..0cbf793 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -91,11 +91,16 @@ for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do for i in {1..${#region_highlight}}; do highlight_zone=${(z)region_highlight[$i]} 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 + if (( start < end )) # region_highlight ranges are half-open + then + (( --end )) # convert to closed range, like expected_region_highlight + (( ++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 + else + # noop range; ignore. + fi done # Then we compare the observed result with the expected one.