canonical repository moved to https://github.com/Perl-Toolchain-Gang/Module-Metadata
[p5sagit/Module-Metadata.git] / t / encoding.t
1 #!perl
2
3 use strict;
4 use warnings;
5 use File::Spec;
6 use Test::More;
7
8 use Module::Metadata;
9
10 if ("$]" < 5.008_003) {
11   plan skip_all => 'Encoding test needs at least perl 5.8.3';
12 }
13
14 my %versions = (
15  UTF8    => 3,
16  UTF16BE => 4,
17  UTF16LE => 5,
18 );
19
20 plan tests => 4 * scalar(keys %versions);
21
22 for my $enc (sort keys %versions) {
23   my $pkg  = "BOMTest::$enc";
24   my $vers = $versions{$enc};
25   my $pm   = File::Spec->catfile(qw<t lib BOMTest> => "$enc.pm");
26   my $info = Module::Metadata->new_from_file($pm);
27   is( $info->name, $pkg, "$enc: default package was found" );
28   is( $info->version, $vers, "$enc: version for default package" );
29   is( $info->version('Heart'), '1', 'version for ASCII package' );
30   is( $info->version("C\x{153}ur"), '2', 'version for Unicode package' );
31 }