Created
January 1, 2012 03:39
-
-
Save karronoli/1546165 to your computer and use it in GitHub Desktop.
todo_output bug? for Test::More->builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Test::More; | |
use Encode::Locale; | |
use Encode; | |
my $eco = find_encoding($Encode::Locale::ENCODING_CONSOLE_OUT); | |
diag($Encode::Locale::ENCODING_CONSOLE_OUT); | |
=pod Windows + cp932環境で日本語のテストケース名を出力する例 | |
Test::More->builderを操作する前なら一つずつencodeすれば問題ない | |
builder経由だと成功時の出力と失敗時の出力を両方操作しておけば問題なさそう. | |
だけとtodo_outputを操作するとアレコレ化ける. | |
=cut | |
ok 0, $eco->encode('日本語のテストケース名 by Encode(fail)'); | |
ok 1, $eco->encode('日本語のテストケース名 by Encode(success)'); | |
my $builder = Test::More->builder; | |
binmode $builder->output, ':encoding(console_out)'; | |
binmode $builder->failure_output, ':encoding(console_out)'; | |
ok 0, '日本語のテストケース名 by builder(fail)'; | |
ok 1, '日本語のテストケース名 by builder(success)'; | |
TODO: { | |
# TODOの理由の文字も化けない | |
local $TODO = 'todo_outputを操作する前'; | |
ok 0, '日本語のテストケース名 by builder(fail + todo)'; | |
ok 1, '日本語のテストケース名 by builder(success + todo)'; | |
}; | |
# todo_output以後は文字化け | |
binmode $builder->todo_output, ':encoding(console_out)'; | |
# 失敗コメント中だけは化けない | |
ok 0, '日本語のテストケース名 by builder(fail + after todo_output)'; | |
ok 1, '日本語のテストケース名 by builder(success + after todo_output)'; | |
TODO: { | |
local $TODO = 'todo_outputを操作した後'; | |
ok 0, '日本語のテストケース名 by builder(fail + todo)'; | |
ok 1, '日本語のテストケース名 by builder(success + todo)'; | |
}; | |
# builderが操作されてるのでencodeしても化ける(当然) | |
# ok 0, $eco->encode('日本語のテストケース名 by Encode'); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment