This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add testsuite portion of patch
[perl5.git] / t / op / lex_assign.t
CommitLineData
317982ac
IZ
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8umask 0;
9$xref = \ "";
10@a = (1..5);
11%h = (1..6);
12$aref = \@a;
13$href = \%h;
14open OP, qq{$^X -le 'print "aaa Ok ok" while \$i++ < 100'|};
15$chopit = 'aaaaaa';
16@chopar = (113 .. 119);
17$posstr = '123456';
18$cstr = 'aBcD.eF';
19pos $posstr = 3;
20$nn = $n = 2;
21sub subb {"in s"}
22
23@INPUT = <DATA>;
24print "1..", (scalar @INPUT), "\n";
25$ord = 0;
26
27sub wrn {"@_"}
28
29for (@INPUT) {
30 $ord++;
31 ($op, undef, $comment) = /^([^\#]+)(\#\s+(.*))?/;
32 $comment = $op unless defined $comment;
33 $op = "$op==$op" unless $op =~ /==/;
34 ($op, $expectop) = $op =~ /(.*)==(.*)/;
35
36 $skip = ($op =~ /^'\?\?\?'/) ? "skip" : "not";
37 $integer = ($comment =~ /^i_/) ? "use integer" : '' ;
38 (print "#skipping $comment:\nok $ord\n"), next if $skip eq 'skip';
39
40 eval <<EOE;
41 local \$SIG{__WARN__} = \\&wrn;
42 my \$a = 'fake';
43 $integer;
44 \$a = $op;
45 \$b = $expectop;
46 if (\$a ne \$b) {
47 print "# \$comment: got `\$a', expected `\$b'\n";
48 print "\$skip " if \$a ne \$b or \$skip eq 'skip';
49 }
50 print "ok \$ord\\n";
51EOE
52 if ($@) {
53 if ($@ =~ /is unimplemented/) {
54 print "# skipping $comment: unimplemented:\nok $ord\n";
55 } else {
56 warn $@;
57 print "not ok $ord\n";
58 }
59 }
60}
61__END__
62ref $xref # ref
63ref $cstr # ref nonref
64`ls` # backtick
65`$undefed` # backtick undef
66<*> # glob
67<OP> # readline
68'faked' # rcatline
69(@z = (1 .. 3)) # aassign
70chop $chopit # chop
71(chop (@x=@chopar)) # schop
72chomp $chopit # chomp
73(chop (@x=@chopar)) # schomp
74pos $posstr # pos
75pos $chopit # pos returns undef
76$nn++==2 # postinc
77$nn++==3 # i_postinc
78$nn--==4 # postdec
79$nn--==3 # i_postdec
80$n ** $n # pow
81$n * $n # multiply
82$n * $n # i_multiply
83$n / $n # divide
84$n / $n # i_divide
85$n % $n # modulo
86$n % $n # i_modulo
87$n x $n # repeat
88$n + $n # add
89$n + $n # i_add
90$n - $n # subtract
91$n - $n # i_subtract
92$n . $n # concat
93$n . $a=='2fake' # concat with self
94"3$a"=='3fake' # concat with self in stringify
95"$n" # stringify
96$n << $n # left_shift
97$n >> $n # right_shift
98$n <=> $n # ncmp
99$n <=> $n # i_ncmp
100$n cmp $n # scmp
101$n & $n # bit_and
102$n ^ $n # bit_xor
103$n | $n # bit_or
104-$n # negate
105-$n # i_negate
106~$n # complement
107atan2 $n,$n # atan2
108sin $n # sin
109cos $n # cos
110'???' # rand
111exp $n # exp
112log $n # log
113sqrt $n # sqrt
114int $n # int
115hex $n # hex
116oct $n # oct
117abs $n # abs
118length $posstr # length
119substr $posstr, 2, 2 # substr
120vec("abc",2,8) # vec
121index $posstr, 2 # index
122rindex $posstr, 2 # rindex
123sprintf "%i%i", $n, $n # sprintf
124ord $n # ord
125chr $n # chr
126crypt $n, $n # crypt
127ucfirst ($cstr . "a") # ucfirst padtmp
128ucfirst $cstr # ucfirst
129lcfirst $cstr # lcfirst
130uc $cstr # uc
131lc $cstr # lc
132quotemeta $cstr # quotemeta
133@$aref # rv2av
134@$undefed # rv2av undef
135each %h==1 # each
136values %h # values
137keys %h # keys
138%$href # rv2hv
139pack "C2", $n,$n # pack
140split /a/, "abad" # split
141join "a"; @a # join
142push @a,3==6 # push
143unshift @aaa # unshift
144reverse @a # reverse
145reverse $cstr # reverse - scal
146grep $_, 1,0,2,0,3 # grepwhile
147map "x$_", 1,0,2,0,3 # mapwhile
148subb() # entersub
149caller # caller
150warn "ignore this\n" # warn
151'faked' # die
152open BLAH, "<non-existent" # open
153fileno STDERR # fileno
154umask 0 # umask
155select STDOUT # sselect
156select "","","",0 # select
157getc OP # getc
158'???' # read
159'???' # sysread
160'???' # syswrite
161'???' # send
162'???' # recv
163'???' # tell
164'???' # fcntl
165'???' # ioctl
166'???' # flock
167'???' # accept
168'???' # shutdown
169'???' # ftsize
170'???' # ftmtime
171'???' # ftatime
172'???' # ftctime
173chdir 'non-existent' # chdir
174'???' # chown
175'???' # chroot
176unlink 'non-existent' # unlink
177chmod 'non-existent' # chmod
178utime 'non-existent' # utime
179rename 'non-existent', 'non-existent1' # rename
180link 'non-existent', 'non-existent1' # link
181symlink 'non-existent', 'non-existent1' # symlink
182readlink 'non-existent', 'non-existent1' # readlink
183'???' # mkdir
184'???' # rmdir
185'???' # telldir
186'???' # fork
187'???' # wait
188'???' # waitpid
189system 'sh -c true' # system
190'???' # exec
191kill 0, $$ # kill
192getppid # getppid
193getpgrp # getpgrp
194'???' # setpgrp
195getpriority $$, $$ # getpriority
196'???' # setpriority
197time # time
198localtime # localtime
199gmtime # gmtime
200sleep 1 # sleep
201'???' # alarm
202'???' # shmget
203'???' # shmctl
204'???' # shmread
205'???' # shmwrite
206'???' # msgget
207'???' # msgctl
208'???' # msgsnd
209'???' # msgrcv
210'???' # semget
211'???' # semctl
212'???' # semop
213'???' # getlogin
214'???' # syscall