til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as a developer

View project on GitHub

Test::Pretty

Test::Pretty is a nifty output prettifier for unit-tests for Perl development.

If you do not see the expected output and the nice UTF-8 checkmark is replaced with an ‘o’, you need to check your terminal settings. Test::Pretty relies on Term::Encoding, which again uses I18N::Langinfo. So make sure that your locale settings lets Test::Pretty aware of UTF-8.

This is a basic test of whether you can render the checkmark:

$ perl -e 'binmode(STDOUT, ":utf8"); print "\x{2713}\n";'

The following test tells you what I18N::Langinfo resolves:

$ perl -MI18N::Langinfo -e 'print I18N::Langinfo::langinfo
(I18N::Langinfo::CODESET())."\n"'
UTF-8

I18N::Langinfo was first released with perl v5.7.3

The following test tells you what Term::Encoding resolves:

$ perl -MTerm::Encoding -e 'print Term::Encoding::term_encoding()."\n"'
utf-8

References