aboutsummaryrefslogtreecommitdiff
path: root/tests/variable/target-type-pattern-specific
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-05-25 11:19:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-05-28 10:10:44 +0200
commit6b3e75edf034ebcbd048a24c283c7bcf7b1da019 (patch)
tree4dff34692fd09c6f201a486c0d92549adc864947 /tests/variable/target-type-pattern-specific
parentbb02e152dc036879ab0b2d1d8aa2cb19084b8e16 (diff)
Add support for regex-based target type/pattern specific variables
This is in addition to the already supported path-based target type/pattern specific variables. For example: hxx{*}: x = y # path-based hxx{~/.*/}: x = y # regex-based
Diffstat (limited to 'tests/variable/target-type-pattern-specific')
-rw-r--r--tests/variable/target-type-pattern-specific/testscript127
1 files changed, 127 insertions, 0 deletions
diff --git a/tests/variable/target-type-pattern-specific/testscript b/tests/variable/target-type-pattern-specific/testscript
index 1a3e98a..9962342 100644
--- a/tests/variable/target-type-pattern-specific/testscript
+++ b/tests/variable/target-type-pattern-specific/testscript
@@ -19,6 +19,65 @@ X
y Y
EOO
+: old-tests-type-pattern
+:
+$* <<EOI >>EOO
+dir{*}: x = y
+
+x = z
+dir{*-foo}: x = $x # 'z'
+print $(bar-foo/: x)
+
+x = G
+file{*-foo}: x = x
+file{xfoo}: x = $x # 'G'
+print $(file{xfoo}: x)
+file{-foo}: x = $x # 'x'
+print $(file{-foo}: x)
+file{x-foo}: x = $x # 'x'
+print $(file{x-foo}: x)
+file{bar-*-foo}: x = X
+file{bar-x}: x = $x # 'G'
+print $(file{bar-x}: x)
+file{bar--foo}: x = $x # 'X'
+print $(file{bar--foo}: x)
+file{bar-x-foo}: x = $x # 'X'
+print $(file{bar-x-foo}: x)
+
+file{*-fox}: x = 1
+file{fox-*}: x = 2
+file{fox-fox}: x = $x # '2'
+print $(file{fox-fox}: x)
+file{*-fox}: x = 3
+file{fox-x-fox}: x = $x # still '2'!
+print $(file{fox-fox}: x)
+
+*-foz: x = z # any target
+file{x-foz}: x = $x # 'z'
+print $(file{x-foz}: x)
+
+*: x1 = X1
+{*}: x2 = X2
+*{*}: x3 = X3
+print $(file{x}: x1)
+print $(file{x}: x2)
+print $(file{x}: x3)
+EOI
+z
+G
+x
+x
+G
+X
+X
+2
+2
+z
+X1
+X2
+X3
+EOO
+
: block
:
$* <<EOI >>EOO
@@ -55,3 +114,71 @@ EOI
X
y Y
EOO
+
+: regex
+:
+{
+ : flag-icase
+ :
+ $* <<EOI >>EOO
+ file{~/'.+\.txt'/i}: x = 1
+
+ print $(file{foo.txt}: x)
+ print $(file{foo.TXT}: x)
+ EOI
+ 1
+ 1
+ EOO
+
+ : flag-match-ext
+ :
+ $* <<EOI >>EOO
+ define txt: file
+
+ txt{*}: x = 0
+ txt{~/'[^.]+'/}: x = 1
+ txt{~/'.+\.tx'/e}: x = 2
+ txt{~/'.+\.txt'/e}: x = 3
+
+ print $(txt{foo.x}: x)
+ print $(txt{foo.tx}: x)
+ print $(txt{foo.txt}: x)
+ print $(txt{foo.bar...}: x)
+ EOI
+ 1
+ 2
+ 3
+ 0
+ EOO
+
+ : backref
+ :
+ $* <<EOI >>EOO
+ x = 0
+ file{~/'(.+)-\1'/}: x = 1
+
+ print $(file{foo-foo}: x)
+ print $(file{foo-bar}: x)
+ EOI
+ 1
+ 0
+ EOO
+
+ : dir
+ :
+ $* <<EOI >>EOO
+ foo/dir{~/b.+/}: x = 1
+
+ print $(foo/dir{bar}: x)
+ EOI
+ 1
+ EOO
+
+ : invalid
+ :
+ $* <<EOI 2>>~/EOE/ != 0
+ file{~/'(.+'/}: x = 1
+ EOI
+ /<stdin>:1:1: error: invalid regex pattern .+/
+ EOE
+}