diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-07 13:51:08 +0300 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-08 08:48:08 +0200 |
commit | 30e991722c35e15c1343cc8772c69a00a5e06d96 (patch) | |
tree | 07a4782021b11e364c7fcff89f0fff5f4e41c0c3 /tests | |
parent | c1d9c1a0db041def6a3bc9b19be9f14a75b72c1a (diff) |
Add $regex.replace_lines() function
Diffstat (limited to 'tests')
-rw-r--r-- | tests/function/regex/testscript | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/function/regex/testscript b/tests/function/regex/testscript index 6ee4c4d..091c28a 100644 --- a/tests/function/regex/testscript +++ b/tests/function/regex/testscript @@ -129,6 +129,88 @@ EOE } +: replace_lines +: +{ + : untyped + : + { + : return-list + : + { + : non-null-fmt + : + $* <<EOI >'foo.hxx bar.txt' + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', '\1.hxx') + EOI + + : null-fmt + : + $* <<EOI >'bar.txt' + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', [null]) + EOI + } + + : return-lines + : + : Note that print adds the trailing newline the value it prints. + : + { + : non-null-fmt + : + $* <<EOI >>EOO + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', '\1.hxx', return_lines) + EOI + foo.hxx + bar.txt + EOO + + : null-fmt + : + $* <<EOI >'bar.txt' + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', [null], return_lines) + EOI + } + } + + : strings + : + { + : return-list + : + $* <<EOI >'foo.hxx bar.txt' + v = [string] "foo.cxx + bar.txt" + + print $regex.replace_lines($v, [string] '(.*)\.cxx', [string] '\1.hxx') + EOI + + : return-lines + : + $* <<EOI >>EOO + v = [string] "foo.cxx + bar.txt" + + print $regex.replace_lines($v, [string] '(.*)\.cxx', [string]'\1.hxx', return_lines) + EOI + foo.hxx + bar.txt + EOO + } +} + : match : { |