diff options
author | 2013-07-17 01:35:30 -0700 | |
---|---|---|
committer | 2013-07-17 01:35:30 -0700 | |
commit | 1511de68ed847c82989561c2619f5f817097ad38 (patch) | |
tree | 1e2d0bfa3813d9fe3b06d72e309ae87f3a6c63ce /fish_tests.cpp | |
parent | d6c9d3ce948c6bff13431c195f65860b5a1f0230 (diff) |
Make parse_util_locate_cmdsubst return the innermost command substitution instead of the outermost.
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r-- | fish_tests.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp index 2572e8d6..fad9b7ec 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -60,6 +60,7 @@ #include "postfork.h" #include "signal.h" #include "highlight.h" +#include "parse_util.h" /** The number of tests to run @@ -527,6 +528,30 @@ static void test_parser() } } +static void test_utils() +{ + say(L"Testing utils"); + const wchar_t *a = L"echo (echo (echo hi"; + + const wchar_t *begin = NULL, *end = NULL; + parse_util_cmdsubst_extent(a, 0, &begin, &end); + if (begin != a || end - begin != wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + parse_util_cmdsubst_extent(a, 1, &begin, &end); + if (begin != a || end - begin != wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + parse_util_cmdsubst_extent(a, 2, &begin, &end); + if (begin != a || end - begin != wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + parse_util_cmdsubst_extent(a, 3, &begin, &end); + if (begin != a || end - begin != wcslen(begin)) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + + parse_util_cmdsubst_extent(a, 8, &begin, &end); + if (begin != a + wcslen(L"echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + + parse_util_cmdsubst_extent(a, 17, &begin, &end); + if (begin != a + wcslen(L"echo (echo (")) err(L"parse_util_cmdsubst_extent failed on line %ld", (long)__LINE__); + + +} + class lru_node_test_t : public lru_node_t { public: @@ -1747,6 +1772,7 @@ int main(int argc, char **argv) test_tok(); test_fork(); test_parser(); + test_utils(); test_lru(); test_expand(); test_fuzzy_match(); |