This is a followup to the last commit, which was about issue #328.
These tests are taken from the original #328 pull request, with updated
expectations where applicable.
Review-by: Matthew Martin
No test because _zsh_highlight_main__type() falls back to 'type -w' which runs
'rehash' implicitly, so on systems where 'sudo' is installed it's not possible
to simulate its being absent.
Test by forcing _zsh_highlight_main__type() to return 'none' when the
argument is [[ $1 == 'sudo' ]], and: (1) Run 'make test' and confirm
that all tests either pass, or fail and the first test point that fails
is one that expects "sudo" at command position to be highlighted as
'command'; (2) In an interactive zsh, 'sudo' at command position is
highlighted as an error.
The functions can remain defined because, nowadays, the test harness
runs each test in a subshell; but that's a well-known property of the
test harness so need not be mentioned explicitly.
Inspired by discussion on issue #443.
Merge remote-tracking branch 'upstream/pr/385'
* upstream/pr/385:
'main': Add regression test for previous commit.
'main': Fix bug: no start_pos=$end_pos in comment short path
Fixes#385.
Such a command word would, if not valid, fall through to the `type -w` case,
where the output would be misparsed, consequently the forward-compatible [arg0]
style would be used.
The fallback style name uses '_' in anticipation of a future auto-fallback
feature keyed on style names.
'arg0' was previously known as 'commandtypefromthefuture'.
Main highlighter run on itself, on the optimized version:
- optimized (8 runs, 3 last noted):
1.1201650000
1.1074430000
1.1263810000
- unoptimized (8 runs, 3 last noted):
1.5746400000
1.5115250000
1.5155440000
Average difference: 0.415907
Running main highlighter on itself (both runs are on the optimized
version):
- clean (8 runs, last 3 noted):
1.7007670000
1.7330720000
1.7038810000
- optimized (8 runs, last 3 noted):
1.5007230000
1.5142960000
1.4973320000
Average difference: 0.208456
When parsing main-highlighter with itself, the *_check_path function is
called 426 times. Note that there are 686 region_highlight resulting
entries.