diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-02-24 21:23:37 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-02-24 22:42:42 -0600 |
commit | a2855ff136611cedfac668f685902e3567240b57 (patch) | |
tree | c2b835dad610a138a9791a6fa2fd0c0543add646 /t/003-comments.t | |
parent | f0a9c930a9e16efb964190cdb9059610668b098e (diff) | |
download | locale-pofilemanager-a2855ff136611cedfac668f685902e3567240b57.tar.gz locale-pofilemanager-a2855ff136611cedfac668f685902e3567240b57.zip |
tests for preserving comments
Diffstat (limited to 't/003-comments.t')
-rw-r--r-- | t/003-comments.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/003-comments.t b/t/003-comments.t new file mode 100644 index 0000000..529791e --- /dev/null +++ b/t/003-comments.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use File::Temp; +use File::Copy; +use Path::Class; + +use Locale::POFileManager; + +{ + my $dir = File::Temp->newdir; + my $from_dir = dir('t/data/003'); + my $tmpdir = dir($dir->dirname); + for my $file ($from_dir->children) { + copy($file->stringify, $dir->dirname); + } + + my $manager = Locale::POFileManager->new( + base_dir => $dir->dirname, + canonical_language => 'en', + ); + $manager->add_stubs; + + is($tmpdir->file('en.po')->slurp, $from_dir->file('en.po')->slurp, + "canonical file untouched"); + + my $expected = $from_dir->file("de.po")->slurp; + my $got = $tmpdir->file("de.po")->slurp; + my $fixed = substr $got, 0, length($expected), ''; + is($fixed, $expected, "original part of the file wasn't touched"); + is(substr($got, 0, 1, ''), "\n", "spacing newline added properly"); + is_deeply([sort split /\n\n/, $got], + [qq{msgid "quuux"}, qq{msgid "quux"}], + "added the correct stubs"); +} + +done_testing; |