Commit graph

122 commits

Author SHA1 Message Date
Daniel Shahaf
14711a51f3 tests: Explicitly test 'default' style inside an array assignment. 2016-06-03 02:41:10 +00:00
m0viefreak
6cd39e7c70 'main': Highlight path separators
This commit is based on the work done by
Jorge Israel Peña (blaenk) in #136.

Changes:
* Adjusted to changes on the latest master branch.
* Use regular path highlighter colors by default.
* Break out early if the separator color is the same to
  improve performance.
* Tests.
2016-05-31 15:06:12 +00:00
m0viefreak
12b879caf7 'main': Use zsh/parameter instead of type -w
If possible, try to use the zsh/parameter module to get
information about a shell words.

This avoids subshells and is a huge speed improvement
on systems such as cygwin.

Note 1:
$commands does not know about PATH_DIRS. So in case
PATH_DIRS is set, 'type -w' is still used if nothing
else matches.

Note 2:
zsh/parameter can't distinguish between 'command' and
'hashed'. Adjusted the test for that case to XFAIL.

The ideal solution would be if whence had an option to
put the result in REPLY instead of printing it to stdout.
2016-05-13 20:25:07 +02:00
Daniel Shahaf
4f5bb6cf96 Merge remote-tracking branch 'upstream/pr/308' into HEAD
* upstream/pr/308:
  'main': Fix issue #302, "Process substitution misparsed as redirection".
  'main': Factor out common code.  No functional change.
  'main': Add a regression test for issue #302, "Process substitution misparsed as redirection".
2016-05-13 01:24:01 +00:00
Daniel Shahaf
62f1c108f3 tests: New test to capture off-by-ones.
Inspired by #312.
2016-05-11 20:36:18 +00:00
Daniel Shahaf
fc9c892a3f 'main': Fix issue #302, "Process substitution misparsed as redirection". 2016-05-09 03:29:27 +00:00
Daniel Shahaf
6889ff6bd2 'main': Add a regression test for issue #302, "Process substitution misparsed as redirection". 2016-05-09 03:26:06 +00:00
Matthew Martin
d3678ec7a8 tests: Remove unused_highlight 2016-05-05 12:28:43 -05:00
Matthew Martin
a830613467 tests: Specify the style key instead of the style itself 2016-04-29 09:51:13 -05:00
Matthew Martin
78290e043b tests: Expect the correct style 2016-04-03 20:43:13 -05:00
Matthew Martin
31ac2b36a9 tests: Quote style in expected_region_highlight 2016-04-02 09:45:24 -05:00
Daniel Shahaf
4c23a2fd1b 'main': Highlight lone '!' correctly: it's not a history expansion.
While here, also add a test for the '!' reserved word (which is highlighted
since c216242b).
2016-03-13 02:47:25 +00:00
Daniel Shahaf
28932316cc aliases: Highlight aliases with '=' in their LHS as error. (Part of issue #263.) 2016-01-11 15:27:48 +00:00
Daniel Shahaf
5e4b446dee aliases: Add a test for one variant of issue #263. 2016-01-11 15:07:18 +00:00
Daniel Shahaf
73ee7c1f6c Fix part of issue #238, "fd redirections at command word".
This fixes fd's specified by a (single) digit.  The named fd syntax remains an XFail.
2015-11-29 03:16:01 +00:00
Daniel Shahaf
48ecd29180 tests: Add two XFail tests for issue #238, "fd redirections at command word". 2015-11-29 03:15:55 +00:00
Daniel Shahaf
430cf55368 tests: Cover [default]. 2015-11-29 02:56:07 +00:00
Daniel Shahaf
46cd970bc4 tests: Improve tests by using $unused_highlight.
The default for [redirection] is 'none', so it wasn't actually being tested.
2015-11-29 02:53:58 +00:00
Daniel Shahaf
09c4114eb9 command word: Do not attempt to interpret command separator tokens as anything else.
The important part of this change is removing the second conjunct from the
condition; the remainder of the change gives one example of when that matters.
2015-11-29 02:02:42 +00:00
Daniel Shahaf
29fd6ec1de Support the '|&', '&!', '&|' command separators. 2015-11-17 20:19:19 +00:00
Daniel Shahaf
79b95c629e Drop unnecessary shebang lines.
Done in c30301d474 and
c687bddea3 for other tests.
2015-11-17 02:04:23 +00:00
Daniel Shahaf
3669d69226 Fix copyright year. 2015-11-17 02:02:42 +00:00
Daniel Shahaf
4fcfb15913 Highlight parameter expansions that are a command word.
Fixes zsh-users/zsh-syntax-highlighting#101.
2015-11-17 01:37:58 +00:00
Daniel Shahaf
6e3720f39d dollar-double-quoted-argument: Support the syntax «"${foo}"». (Issue #186.) 2015-11-17 00:40:02 +00:00
Daniel Shahaf
28776371a0 tests: Add an XFail test for highlighting «"${foo}"». (Issue #186.) 2015-11-17 00:37:58 +00:00
Daniel Shahaf
96ee5116b1 Fix issue #228, "Support the PATH_DIRS option". 2015-11-16 23:14:48 +00:00
Daniel Shahaf
a636527f70 tests: Add an XFail test for issue #228, "Support the PATH_DIRS option".
This builds upon the test harness auto-cleaned-up directories work (c01533920).
2015-11-16 23:04:11 +00:00
Daniel Shahaf
2b35ff1c15 minor: Rename a test file to a not-escape-needing name.
There's simply no reason to use such names, now that the filename is no longer
itself test data.
2015-11-16 22:57:47 +00:00
Daniel Shahaf
c015339202 tests: Provide an independent, auto-cleaned working directory to each test.
Fixes zsh-users/zsh-syntax-highlighting#182.
Prerequisite for testing issue #228.

* tests/test-highlighting.zsh
  (run_test): Move functionality to run_test_internal; make run_test be a wrapper
    that handles creating and cleaning up the tempdir.

* tests/README.md: Document the new feature.

* "highlighters/main/test-data/path-space- .zsh"
* highlighters/main/test-data/path-tilde-named.zsh
* highlighters/main/test-data/path.zsh
    Change test data to not depend on being run from the source directory.
2015-11-16 22:54:52 +00:00
Daniel Shahaf
3620ad951f Add an XFail test for issue #231, "Assignment terminating subshell flags closing parenthesis as an error". 2015-11-16 19:04:37 +00:00
Daniel Shahaf
b285c7b821 brackets: Highlight closing ')' of array assignments correctly. (Issue #226.)
Followup to c0dafd1d85, which changed the highlight of
those ')'s from <nothing> to [reserved-word].
2015-11-16 18:44:44 +00:00
Daniel Shahaf
c0dafd1d85 brackets: Highlight the closing brackets of subshells and blocks. (Issue #226.) 2015-10-30 20:20:30 +02:00
Daniel Shahaf
a59f442d2d brackets: Highlight the closing brackets of arithmetic expansion. (Issue #226.) 2015-10-30 17:28:48 +00:00
Daniel Shahaf
8b4adbd991 Fix issue #222, "command word after repeat". 2015-10-30 13:31:43 +00:00
Daniel Shahaf
6fbd2aa957 Add an XFail test for issue #222, "command word after repeat". 2015-10-30 13:31:23 +00:00
Daniel Shahaf
9e178f9f39 subshells: Highlight the opening parenthesis correctly. (Issue #166.)
Followup to 0d1bfbcbfa.
2015-10-30 11:38:32 +02:00
Daniel Shahaf
5a38710564 subshells: Add an XFail test demonstrating that #166 is not yet fixed.
Reported-by: Antony Lee
2015-10-30 09:34:01 +00:00
Daniel Shahaf
1ac39b0af1 comments: Mark prematurely-terminated command as an error.
This is already done for commands prematurely terminated by ";".
2015-10-30 08:38:45 +02:00
Daniel Shahaf
693de99a90 comments: Fix issue #163 and #167: Highlight comments. 2015-10-30 08:38:44 +02:00
Daniel Shahaf
e76f208cf8 comments: Add a PASSing test for the NO_INTERACTIVE_COMMENTS case. 2015-10-30 08:38:39 +02:00
Daniel Shahaf
e9ceb2017e comments: Add XFail tests from issues #163 and #167.
These tests are based on the patches contributed in those issues:

    commit 9d9df4fe80 (upstream/pr/167)
    Author:     Miciah Masters <miciah.masters@gmail.com>
    AuthorDate: Thu Apr 23 20:28:24 2015 -0400
    Commit:     Miciah Dashiel Butler Masters <mmasters@redhat.com>
    CommitDate: Thu Apr 23 20:28:24 2015 -0400

        Highlight comments

    M       highlighters/main/main-highlighter.zsh
    A       highlighters/main/test-data/comments.zsh

    commit d94f1a037f (upstream/pr/163)
    Author:     sonnym <michaud.sonny@gmail.com>
    AuthorDate: Fri Mar 6 18:27:57 2015 -0500
    Commit:     sonnym <michaud.sonny@gmail.com>
    CommitDate: Fri Mar 6 21:16:27 2015 -0500

        highlight comments when interactive_comments is on

    M       highlighters/main/main-highlighter.zsh
    A       highlighters/main/test-data/comment-embedded.zsh
    A       highlighters/main/test-data/comment-leading.zsh

Patch-by: sonnym <michaud.sonny@gmail.com>
Patch-by: Miciah Masters <miciah.masters@gmail.com>
(corrected and refreshed for harness changes by me)
2015-10-29 18:08:30 +02:00
Daniel Shahaf
2f05620b19 sudo: Flag an error when a required argument is missing. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
f49f3bf0c0 sudo: Extend tests. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
a3047a9121 sudo: Highlight an empty sudo; as an error.
The word following 'sudo' was considered :regular:, although it isn't.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
86e9249709 sudo/redirections: Fix remaining part of issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
0d1bfbcbfa Highlight subshells and anonymous functions correctly.
Fixes zsh-users/zsh-syntax-highlighting#166.
Fixes zsh-users/zsh-syntax-highlighting#194.
Builds upon the issue #207 work.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
2218e26bf8 command word: Highlight 'else' correctly. Part of issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
b397b12ac1 command word: Start fixing issue #207, "Word following certain reserved words should be a command word". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
87deac3062 command word: Add an XFail test for issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
01d7eeb3c7 Fix issue #205, "';' after assignment is highlighted as unknown-token". 2015-10-29 12:01:13 +00:00