This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add tests for (?{ return foo })
authorDavid Mitchell <davem@iabyn.com>
Wed, 6 Jun 2012 09:39:26 +0000 (10:39 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Jun 2012 12:32:56 +0000 (13:32 +0100)
All types of code blocks make use of the return value from the code
block. Check they all work, with and without an explicit 'return'.

t/re/re_tests

index e54c3ab..b636707 100644 (file)
@@ -1642,4 +1642,14 @@ ab[c\\\](??{"x"})]{3}d   ab\\](d y       -       -
 ^(.)(B)*.[DX]  ABCDE   y       $^N-$+  B-B     -
 ^(.)(B)*.[CX]  ABCDE   y       $^N-$+  A-A     -
 
+# using 'return' in code blocks
+^(A)(?{"xyz"})B$       AB      y       $1-$^R  A-xyz   -
+^(A)(?{return "xyz"})B$        AB      y       $1-$^R  A-xyz   -
+^(A)((??{"xyz"}))$     Axyz    y       $1-$2   A-xyz   -
+^(A)((??{return "xyz"}))$      Axyz    y       $1-$2   A-xyz   -
+^(A)((?(?{1})abc|xyz))$        Aabc    y       $1-$2   A-abc   -
+^(A)((?(?{0})abc|xyz))$        Axyz    y       $1-$2   A-xyz   -
+^(A)((?(?{return 1})abc|xyz))$ Aabc    y       $1-$2   A-abc   -
+^(A)((?(?{return 0})abc|xyz))$ Axyz    y       $1-$2   A-xyz   -
+
 # vim: softtabstop=0 noexpandtab