2 # Test p55, the "Perl 5 to Perl 5" translator.
4 # The perl core should have MAD enabled ('sh Configure -Dmad=y ...')
6 # The part to convert xml to Perl 5 requires XML::Parser, but it does
7 # not depend on Perl internals, so you can use a stable system wide
10 # For the p55 on the perl test suite, it should be started from the
11 # $perlsource/t subdir
14 # sh Configure -Dmad=y
16 # cd t && /usr/bin/prove ../mad/t/p55.t
25 use Test::More qw|no_plan|;
31 my ($input, $msg) = @_;
34 open my $infile, "> tmp.in";
35 $infile->print($input);
39 `PERL_XMLDUMP='tmp.xml' ../perl -I ../lib tmp.in 2> tmp.err`;
42 return ok 0, "MAD dump failed $msg";
44 my $output = eval { Nomad::xml_to_p5( input => "tmp.xml" ) };
46 is($output, $input, $msg);
50 my @prgs = split m/^########\n/m, <DATA>;
54 for my $prog (@prgs) {
55 my $msg = ($prog =~ s/^#(.*)\n//) && $1;
56 local $TODO = ($msg =~ /TODO/) ? 1 : 0;
62 use Test::Differences;
64 our %failing = map { $_, 1 } qw|
89 find( sub { push @files, $File::Find::name if m/[.]t$/ }, '../t/');
91 for my $file (@files) {
94 local $TODO = (exists $failing{$file} ? "Known failure" : undef);
96 open(my $fh, "<", "$file") or die "Failed open '../t/$file' $!";
97 $input = $fh->getline;
101 if( $input =~ m/^[#][!].*perl(.*)/) {
106 `PERL_XMLDUMP='tmp.xml' ../perl $switches -I ../lib $file 2> tmp.err`;
109 fail "MAD dump failure of '$file'";
112 my $output = eval { Nomad::xml_to_p5( input => "tmp.xml" ) };
114 fail "convert xml to p5 failed file: '$file'";
118 eq_or_diff $output, $input, "p55 '$file'";
132 use encoding 'euc-jp';
133 tr/¤¡-¤ó¥¡-¥ó/¥¡-¥ó¤¡-¤ó/;
136 BEGIN { ok(1, 2, ); }
138 for (my $i=0; $i<3; $i++) { }
140 for (; $a<3; $a++) { }
149 eval { require 5.005 }
151 # TODO Reduced test case from t/io/layers.t
152 sub PerlIO::F_UTF8 () { 0x00008000 } # from perliol.h
153 BEGIN { PerlIO::Layer->find("encoding",1);}
155 # TODO from ../t/op/array.t
158 # TODO from t/comp/parser.t
161 # TODO from t/op/getppid.t
165 use feature 'switch';
166 given(my $x = "bar") { }
168 # TODO attribute t/op/attrhand.t
169 sub something : TypeCheck(
173 ) { # WrongAttr (perl tokenizer bug)
174 # keep this ^ lined up !
178 # TODO symbol table t/op/symbolcache.t
179 sub replaced2 { 'func' }
180 BEGIN { undef $main::{replaced2} }
182 # TODO exit in begin block. from t/op/threads.t without threads