Locale-MO-File
view release on metacpan or search on metacpan
t/12_big_endian.t view on Meta::CPAN
#!perl -T
use strict;
use warnings;
use Carp qw(confess);
use English qw(-no_match_vars $OS_ERROR $INPUT_RECORD_SEPARATOR);
use Hash::Util qw(lock_hash);
use IO::File qw(SEEK_SET);
use Test::More tests => 10;
use Test::NoWarnings;
use Test::Differences;
use Test::Exception;
use Test::HexDifferences;
BEGIN {
require_ok 'Locale::MO::File';
}
my @messages = (
{
msgid => q{},
msgstr => <<'EOT',
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Plural-Forms: nplurals=2; plural=n != 1
EOT
},
{
msgid => 'original',
msgstr => 'translated',
},
{
msgctxt => 'context',
msgid => 'c_original',
msgstr => 'c_translated',
},
{
msgid => 'o_singular',
msgid_plural => 'o_plural',
msgstr_plural => [ qw(t_singular t_plural) ],
},
{
msgctxt => 'c_context',
msgid => 'c_o_singular',
msgid_plural => 'c_o_plural',
msgstr_plural => [ qw(c_t_singular c_t_plural) ],
},
);
for my $message (@messages) {
lock_hash %{$message};
}
my $filename = '12_big_endian.mo';
my @sorted_messages = (
map {
$_->[0];
}
sort {
$a->[1] cmp $b->[1];
}
map {
[
$_,
Locale::MO::File->new(filename => $filename)->_pack_message($_)->{msgid},
];
} @messages
);
my $hex_dump = <<'EOT';
0000 : 950412DE : magic number
0004 : 00000000 : revision
0008 : 00000005 : number of strings
( run in 0.734 second using v1.01-cache-2.11-cpan-6aa56a78535 )