2 my $keep_plc = 0; # set it to keep the bytecode files
3 my $keep_plc_fail = 1; # set it to keep the bytecode files on failures
7 print "1..0 # skip - Bytecode/ByteLoader doesn't work on VMS\n";
12 @INC = ('.', '../lib');
18 if (($Config{'extensions'} !~ /\bB\b/) ){
19 print "1..0 # Skip -- Perl configured without B module\n";
22 if ($Config{ccflags} =~ /-DPERL_OLD_COPY_ON_WRITE/) {
23 print "1..0 # skip - no COW for now\n";
26 require 'test.pl'; # for run_perl()
31 my @tests = split /\n###+\n/, <DATA>;
33 print "1..".($#tests+1)."\n";
40 my ($script, $expect) = split />>>+\n/;
42 $test = "bytecode$cnt.pl";
43 open T, ">$test"; print T $script; close T;
44 $got = run_perl(switches => [ "-MO=Bytecode,-H,-o${test}c" ],
45 verbose => 0, # for debugging
46 stderr => 1, # to capture the "bytecode.pl syntax ok"
49 $got = run_perl(progfile => "${test}c"); # run the .plc
51 if ($got =~ /^$expect$/) {
55 $keep_plc = $keep_plc_fail unless $keep_plc;
78 1 while unlink($test, $keep_plc ? () : "${test}c");
87 ############################################################
88 for (1,2,3) { print if /\d/ }
91 ############################################################
92 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/ge; print $_
95 ############################################################
96 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/g; print $_
99 ############################################################
100 split /a/,"bananarama"; print @_
103 ############################################################
104 { package P; sub x { print 'ya' } x }
107 ############################################################
108 @z = split /:/,"b:r:n:f:g"; print @z
111 ############################################################
112 sub AUTOLOAD { print 1 } &{"a"}()
115 ############################################################
116 my $l = 3; $x = sub { print $l }; &$x
119 ############################################################
121 my $foo = sub {$i = shift if @_};
126 ############################################################
127 $x="Cannot use"; print index $x, "Can"
130 ############################################################
131 my $i=6; eval "print \$i\n"
134 ############################################################
135 BEGIN { %h=(1=>2,3=>4) } print $h{3}
138 ############################################################
143 ############################################################
151 ############################################################
152 BEGIN { tie @a, __PACKAGE__; sub TIEARRAY { bless{} } sub FETCH { 1 } }
156 ############################################################
157 my $i=3; print 1 .. $i
160 ############################################################
161 my $h = { a=>3, b=>1 }; print sort {$h->{$a} <=> $h->{$b}} keys %$h
164 ############################################################
165 print sort { my $p; $b <=> $a } 1,4,3