12 plan skip_all => "unicode on Perl < 5.8.0"
15 plan skip_all => "PERL_UNICODE set"
16 if $ENV{PERL_UNICODE};
18 eval "use File::Temp";
19 plan skip_all => "File::Temp unavailable"
23 plan skip_all => "Encode unavailable"
26 # Subs that take the supplied TAP and turn it into a set of args to
27 # supply to TAP::Harness->new. The returned hash includes the
28 # temporary file so that its reference count doesn't go to zero
29 # until we're finished with it.
33 my $tmp = File::Temp->new;
34 open my $fh, ">$tmp" or die "Can't write $tmp ($!)\n";
35 eval 'binmode( $fh, ":utf8" )';
36 print $fh join( "\n", @$source ), "\n";
39 open my $taph, "<$tmp" or die "Can't read $tmp ($!)\n";
40 eval 'binmode( $taph, ":utf8" )';
43 args => { source => $taph },
48 my $tmp = File::Temp->new;
49 open my $fh, ">$tmp" or die "Can't write $tmp ($!)\n";
50 eval 'binmode( $fh, ":utf8" )';
51 print $fh map {"print qq{$_\\n};\n"} @$source;
54 open my $taph, "<$tmp" or die "Can't read $tmp ($!)\n";
57 args => { exec => [ $^X, "$tmp" ] },
63 { name => 'Non-unicode warm up',
67 'ok 1 Everything is fine',
70 { isa => 'TAP::Parser::Result::Version', },
71 { isa => 'TAP::Parser::Result::Plan', },
72 { isa => 'TAP::Parser::Result::Test',
73 description => "Everything is fine"
77 { name => 'Unicode smiley',
82 # Funky quoting / eval to avoid errors on older Perls
83 eval qq{"ok 1 Everything is fine \\x{263a}"},
86 { isa => 'TAP::Parser::Result::Version', },
87 { isa => 'TAP::Parser::Result::Plan', },
88 { isa => 'TAP::Parser::Result::Test',
89 description => eval qq{"Everything is fine \\x{263a}"}
98 for my $test (@schedule) {
99 for my $type ( sort keys %make_test ) {
100 my $name = sprintf( "%s (%s)", $test->{name}, $type );
101 my $args = $make_test{$type}->( $test->{source} );
103 my $parser = TAP::Parser->new( $args->{args} );
104 isa_ok $parser, 'TAP::Parser';
105 my @expect = @{ $test->{expect} };
106 while ( my $tok = $parser->next ) {
107 my $exp = shift @expect;
108 for my $item ( sort keys %$exp ) {
109 my $val = $exp->{$item};
110 if ( 'isa' eq $item ) {
113 elsif ( 'CODE' eq ref $val ) {
114 ok $val->($tok), "$name: assertion for $item";
117 my $got = $tok->$item();
118 is $got, $val, "$name: value for $item matches";