From 30e991722c35e15c1343cc8772c69a00a5e06d96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 7 Nov 2019 13:51:08 +0300 Subject: Add $regex.replace_lines() function --- tests/function/regex/testscript | 82 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'tests/function/regex/testscript') 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 + : + $* <'foo.hxx bar.txt' + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', '\1.hxx') + EOI + + : null-fmt + : + $* <'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 + : + $* <>EOO + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', '\1.hxx', return_lines) + EOI + foo.hxx + bar.txt + EOO + + : null-fmt + : + $* <'bar.txt' + v = "foo.cxx + bar.txt" + + print $regex.replace_lines($v, '(.*)\.cxx', [null], return_lines) + EOI + } + } + + : strings + : + { + : return-list + : + $* <'foo.hxx bar.txt' + v = [string] "foo.cxx + bar.txt" + + print $regex.replace_lines($v, [string] '(.*)\.cxx', [string] '\1.hxx') + EOI + + : return-lines + : + $* <>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 : { -- cgit v1.1