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