From ef1459feaf422fbbb069f2525547ef9b2204ccdf Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 26 Sep 2017 02:17:48 +0300 Subject: Allow pattern group to start with inclusion --- tests/name/pattern.test | 114 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 29 deletions(-) (limited to 'tests') diff --git a/tests/name/pattern.test b/tests/name/pattern.test index b5b0bea..00838d0 100644 --- a/tests/name/pattern.test +++ b/tests/name/pattern.test @@ -45,13 +45,19 @@ EOI : simple : $* <'print {*.txt +foo file{bar}}' 2>>EOE != 0 - :1:8: error: invalid 'file{bar}' in name pattern + :1:19: error: name pattern inclusion or exclusion expected EOE : inclusion-exclusion-sign : $* <'print {*.txt -foo bar}' 2>>EOE != 0 - :1:8: error: missing leading +/- in 'bar' name pattern + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : inclusion-quoted + : + $* <'print {*.txt -foo "+bar"}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected EOE : empty-inclusion-exclusion @@ -79,6 +85,9 @@ EOI touch foo.txt; $* <'print {*.txt}' >'foo.txt' : group + touch foo.txt; + $* <'print {+*.txt}' >'foo.txt' : plus-prefixed + mkdir dir && touch dir/foo.txt; $* <'print dir/{*.txt}' >'dir/foo.txt' : dir @@ -190,38 +199,85 @@ EOI # print dir1/{$pat} # print dir2/{$pat} # + # Instead, he should write it as follows: + # + # pat = '*.txt' + # print dir1/{+$pat} + # print dir2/{+$pat} + # # Note that if we make it work, escaping this case will be pretty hairy: # # filters = --include '*.txt' --exclude '*.obj' # options += $filters - #: pattern-via-expansion - #: - #$* <'<*.txt>' - #pat = '*.txt' - #print $pat - #EOI - - #: pattern-via-expansion-list - #: - #$* <'<*.hxx+*.txt>' - #pats = '*.hxx' '+*.txt' - #print {$pats} - #EOI - - #: pattern-via-expansion-type - #: - #$* <'<*.txt>' - #pat = '*.txt' - #print txt{$pat} - #EOI - - #: pattern-via-expansion-dir - #: - #$* <'<*.txt>' - #pat = '*.txt' - #print dir/{$pat} - #EOI + : prefixed-pattern-via-expansion + : + : Pattern is prefixed with the literal unquoted plus character, that is + : stripped. + : + touch foo.txt; + $* <foo.txt + pat = '*.txt' + print {+$pat} + EOI + + : non-prefixed-pattern-via-concat-expansion + : + : Plus character is a part of the pattern and so is not stripped. + : + touch +foo.txt; + $* <'+foo.txt' + pat = '+*' + ext = 'txt' + print {$pat.$ext} + EOI + + : not-pattern-expansion + : + $* <'+*.txt' + pat = '+*.txt' + print {$pat} + EOI + + : not-pattern-quoted + : + $* <'+*.txt' + print {'+*.txt'} + EOI + + : pattern-via-expansion-list + : + touch foo.txt bar.hxx; + $* <'bar.hxx foo.txt' + pats = '*.hxx' '*.txt' + print {+{$pats}} + EOI + + : pattern-via-expansion-type + : + touch foo.txt; + $* <'txt{foo}' + pat = '*' + print txt{+$pat} + EOI + + : pattern-via-expansion-dir + : + mkdir dir; + touch dir/foo.txt; + $* <dir/foo.txt + pat = '*.txt' + print dir/{+$pat} + EOI + + : pattern-via-expansion-dir-type + : + mkdir dir; + touch dir/foo.txt; + $* <dir/txt{foo} + pat = '*' + print dir/txt{+$pat} + EOI : pattern-via-concat : -- cgit v1.1