X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=t%2Ftestwide.t;h=f194d0edff6f0ffd54e185db62090a69715581e9;hb=57d829ae0e2c75828f8ecc9c7139579350927dbc;hp=7f7e3e721684d64d6f9b1e7f3f3faf3514b36a1a;hpb=7f27e55dce5925b2bbe8fcfca64f385e917a52be;p=perltidy.git diff --git a/t/testwide.t b/t/testwide.t index 7f7e3e7..f194d0e 100755 --- a/t/testwide.t +++ b/t/testwide.t @@ -4,7 +4,7 @@ use Test; use Carp; use FindBin; BEGIN {unshift @INC, "./"} -BEGIN {plan tests => 2} +BEGIN {plan tests => 3} use Perl::Tidy; @@ -48,3 +48,34 @@ Perl::Tidy::perltidy( ok($output, $expected_output); +# Test writing encoded output to stdout with the -st flag +# References: RT #133166, RT #133171, git #35 +$output = ""; +do { + + # Send STDOUT to a temporary file + use File::Temp (); + my $fh = new File::Temp(); + my $tmpfile = $fh->filename; + + # Note that we are not specifying an encoding here. Perltidy should do that. + local *STDOUT; + open STDOUT, '>', $tmpfile or die "Can't open tmpfile: $!"; + + Perl::Tidy::perltidy( + source => \$source, + ##destination => ... we are using -st, so no destination is specified + perltidyrc => \$perltidyrc, + argv => '-nsyn -st', # added -st + ); + close STDOUT; + + # Read the temporary file back in. Note that here we need to specify + # the encoding. + open TMP, '<', $tmpfile; + binmode TMP, ":raw:encoding(UTF-8)"; + while ( my $line = ) { $output .= $line } +}; + +ok($output, $expected_output); +