summaryrefslogtreecommitdiff
path: root/t/op/subst_amp.t
blob: 71895720f7f654c58b76f944dbb9365c3e7361ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    require Config; import Config;
}

print "1..13\n";

$_ = 'x' x 20; 
s/\d*|x/<$&>/g; 
$foo = '<>' . ('<x><>' x 20) ;
print ($_ eq $foo ? "ok 1\n" : "not ok 1\n#'$_'\n#'$foo'\n");

$t = 'aaa';

$_ = $t;
@res = ();
pos = 1;
s/\Ga(?{push @res, $_, $`})/xx/g;
print "not " unless "$_ @res" eq 'axxxx aaa a aaa aa';
print "ok 2\n";

$_ = $t;
@res = ();
pos = 1;
s/\Ga(?{push @res, $_, $`})/x/g;
print "not " unless "$_ @res" eq 'axx aaa a aaa aa';
print "ok 3\n";

$_ = $t;
@res = ();
pos = 1;
s/\Ga(?{push @res, $_, $`})/xx/;
print "not " unless "$_ @res" eq 'axxa aaa a';
print "ok 4\n";

$_ = $t;
@res = ();
pos = 1;
s/\Ga(?{push @res, $_, $`})/x/;
print "not " unless "$_ @res" eq 'axa aaa a';
print "ok 5\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/xx/g;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxxx aaa a aaa aa';
print "ok 6\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x/g;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axx aaa a aaa aa';
print "ok 7\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/xx/;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxa aaa a';
print "ok 8\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x/;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axa aaa a';
print "ok 9\n";

sub x2 {'xx'}
sub x1 {'x'}

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x2/ge;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxxx aaa a aaa aa';
print "ok 10\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x1/ge;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axx aaa a aaa aa';
print "ok 11\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x2/e;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxa aaa a';
print "ok 12\n";

$a = $t;
@res = ();
pos ($a) = 1;
$a =~ s/\Ga(?{push @res, $_, $`})/x1/e;
print "#'$a' '@res'\nnot " unless "$a @res" eq 'axa aaa a';
print "ok 13\n";