Use appropriate prototype depending on perl version in test.
[catagits/Gitalist.git] / t / 02git_Repository.t
index 885a490..9565143 100644 (file)
@@ -13,14 +13,17 @@ use Test::Exception;
 use Test::utf8;
 use Encode qw/decode_utf8/;
 use Data::Dumper;
+use Scalar::Util qw/set_prototype/;
 
 BEGIN {
     # Mocking to allow testing regardless of the user's locale
-    require I18N::Langinfo;
+    require I18N::Langinfo if $^O ne 'MSWin32';
     no warnings 'redefine';
-    *I18N::Langinfo::langinfo = sub($) {
+    my $stub = sub {
         return "UTF-8" if $_[0] == I18N::Langinfo::CODESET();
     };
+    set_prototype \&$stub, ($] <= 5.008009) ? '$' : '_';
+    *I18N::Langinfo::langinfo = $stub;
     *CORE::GLOBAL::getpwuid = sub {
         wantarray
             ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
@@ -79,6 +82,8 @@ like($proj->head_hash('HEAD'), qr/^([0-9a-fA-F]{40})$/, 'head_hash');
     isa_ok($tree[0], 'Gitalist::Git::Object', 'tree element 0');
 }
 
+$proj->{owner} = decode_utf8("T\x{c3}\x{a9}st") if $^O eq 'MSWin32';
+
 my $owner = $proj->owner;
 is_flagged_utf8($owner, "Owner name is flagged as utf8");
 is_sane_utf8($owner, "Owner name is not double-encoded");