12 like( 'a', qr/^a(?{1})(?:b(?{2}))?/, 'a =~ ab?' );
13 cmp_ok( $^R, '==', 1, '..$^R after a =~ ab?' );
16 unlike( 'abc', qr/^a(?{3})(?:b(?{4}))$/, 'abc !~ a(?:b)$' );
17 ok( !defined $^R, '..$^R after abc !~ a(?:b)$' );
20 like( 'ab', qr/^a(?{5})b(?{6})/, 'ab =~ ab' );
21 cmp_ok( $^R, '==', 6, '..$^R after ab =~ ab' );
24 like( 'ab', qr/^a(?{7})(?:b(?{8}))?/, 'ab =~ ab?' );
26 cmp_ok( $^R, '==', 8, '..$^R after ab =~ ab?' );
29 like( 'ab', qr/^a(?{9})b?(?{10})/, 'ab =~ ab? (2)' );
30 cmp_ok( $^R, '==', 10, '..$^R after ab =~ ab? (2)' );
33 like( 'ab', qr/^(a(?{11})(?:b(?{12})))?/, 'ab =~ (ab)? (3)' );
34 cmp_ok( $^R, '==', 12, '..$^R after ab =~ ab? (3)' );
37 unlike( 'ac', qr/^a(?{13})b(?{14})/, 'ac !~ ab' );
38 ok( !defined $^R, '..$^R after ac !~ ab' );
41 like( 'ac', qr/^a(?{15})(?:b(?{16}))?/, 'ac =~ ab?' );
42 cmp_ok( $^R, '==', 15, '..$^R after ac =~ ab?' );
45 like( 'ab', qr/^a(?{push @ar,101})(?:b(?{push @ar,102}))?/, 'ab =~ ab? with code push' );
46 cmp_ok( scalar(@ar), '==', 2, '..@ar pushed' );
47 cmp_ok( $ar[0], '==', 101, '..first element pushed' );
48 cmp_ok( $ar[1], '==', 102, '..second element pushed' );
51 unlike( 'a', qr/^a(?{103})b(?{104})/, 'a !~ ab with code push' );
52 ok( !defined $^R, '..$^R after a !~ ab with code push' );
55 unlike( 'a', qr/^a(?{push @ar,105})b(?{push @ar,106})/, 'a !~ ab (push)' );
56 cmp_ok( scalar(@ar), '==', 0, '..nothing pushed' );
59 unlike( 'abc', qr/^a(?{push @ar,107})b(?{push @ar,108})$/, 'abc !~ ab$ (push)' );
60 cmp_ok( scalar(@ar), '==', 0, '..still nothing pushed' );
64 like( 'ab', qr/^a(?{push @var,109})(?:b(?{push @var,110}))?/, 'ab =~ ab? push to package var' );
65 cmp_ok( scalar(@var), '==', 2, '..@var pushed' );
66 cmp_ok( $var[0], '==', 109, '..first element pushed (package)' );
67 cmp_ok( $var[1], '==', 110, '..second element pushed (package)' );
70 unlike( 'a', qr/^a(?{push @var,111})b(?{push @var,112})/, 'a !~ ab (push package var)' );
71 cmp_ok( scalar(@var), '==', 0, '..nothing pushed (package)' );
74 unlike( 'abc', qr/^a(?{push @var,113})b(?{push @var,114})$/, 'abc !~ ab$ (push package var)' );
75 cmp_ok( scalar(@var), '==', 0, '..still nothing pushed (package)' );
79 ok( 'ac' =~ /^a(?{30})(?:b(?{31})|c(?{32}))?/, 'ac =~ a(?:b|c)?' );
80 ok( $^R == 32, '$^R == 32' );
84 ok( 'abbb' =~ /^a(?{36})(?:b(?{37})|c(?{38}))+/, 'abbbb =~ a(?:b|c)+' );
85 ok( $^R == 37, '$^R == 37' ) or print "# \$^R=$^R\n";