5 print "1..0 # skip - Bytecode/ByteLoader doesn't work on VMS\n";
10 require './test.pl'; # for run_perl()
14 my $test = 'bytecode.pl';
15 END { 1 while unlink $test, "${test}c" }
18 my @tests = split /\n###+\n/, <DATA>;
20 print "1..".($#tests+1)."\n";
26 my ($script, $expect) = split />>>+\n/;
28 open T, ">$test"; print T $script; close T;
29 $got = run_perl(switches => [ "-MO=Bytecode,-H,-o${test}c" ],
30 verbose => 0, # for debugging
31 stderr => 1, # to capture the "bytecode.pl syntax ok"
34 1 while unlink($test); # nuke the .pl
35 $got = run_perl(progfile => "${test}c"); # run the .plc
37 if ($got =~ /^$expect$/) {
70 ############################################################
71 for (1,2,3) { print if /\d/ }
74 ############################################################
75 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/ge; print $_
78 ############################################################
79 $_ = "xyxyx"; %j=(1,2); s/x/$j{print('z')}/g; print $_
82 ############################################################
83 split /a/,"bananarama"; print @_
86 ############################################################
87 { package P; sub x { print 'ya' } x }
90 ############################################################
91 @z = split /:/,"b:r:n:f:g"; print @z
94 ############################################################
95 sub AUTOLOAD { print 1 } &{"a"}()
98 ############################################################
99 my $l = 3; $x = sub { print $l }; &$x
102 ############################################################
104 my $foo = sub {$i = shift if @_};
106 ############################################################
107 $_="\xff\xff"; use utf8; utf8::encode $_; print $_
110 ############################################################
111 $x="Cannot use"; print index $x, "Can"
114 ############################################################
115 my $i=6; eval "print \$i\n"
118 ############################################################
119 BEGIN { %h=(1=>2,3=>4) } print $h{3}
122 ############################################################
124 ############################################################
132 ############################################################
133 BEGIN { tie @a, __PACKAGE__; sub TIEARRAY { bless{} } sub FETCH { 1 } }
137 ############################################################
138 my $i=3; print 1 .. $i
141 ############################################################
142 my $h = { a=>3, b=>1 }; print sort {$h->{$a} <=> $h->{$b}} keys %$h
145 ############################################################
146 print sort { my $p; $b <=> $a } 1,4,3