This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
5adbc1e878537994e1bb0663ccc762c62d7f8047
[perl5.git] / cpan / CPAN-Meta-YAML / t / 15_multibyte.t
1 #!/usr/bin/perl
2
3 # Testing of META.yml containing AVAR's name
4
5 use strict;
6 BEGIN {
7         $|  = 1;
8         $^W = 1;
9 }
10
11 use File::Spec::Functions ':ALL';
12 use t::lib::Test;
13 use Test::More tests(0, 1, 6);
14 use CPAN::Meta::YAML;
15
16
17
18
19
20 #####################################################################
21 # Testing that Perl::Smith config files work
22
23 my $sample_file = catfile( test_data_directory(), 'multibyte.yml' );
24 my $sample      = load_ok( 'multibyte.yml', $sample_file, 450 );
25
26 # Does the string parse to the structure
27 my $name      = "multibyte";
28 my $yaml_copy = $sample;
29 my $yaml      = eval { CPAN::Meta::YAML->read_string( $yaml_copy ); };
30 is( $@, '', "$name: CPAN::Meta::YAML parses without error" );
31 is( $yaml_copy, $sample, "$name: CPAN::Meta::YAML does not modify the input string" );
32 SKIP: {
33         skip( "Shortcutting after failure", 2 ) if $@;
34         isa_ok( $yaml, 'CPAN::Meta::YAML' );
35         is_deeply( $yaml->[0]->{build_requires}, {
36                 'Config'     => 0,
37                 'Test::More' => 0,
38                 'XSLoader'   => 0,
39         }, 'build_requires ok' );
40 }
41
42 SKIP: {
43         unless ( CPAN::Meta::YAML::HAVE_UTF8() ) {
44                 skip("no utf8 support", 2 );
45         }
46         eval { utf8::is_utf8('') };
47         if ( $@ ) {
48                 skip("no is_utf8 to test with until 5.8.1", 2);
49         }
50         ok( utf8::is_utf8($yaml->[0]->{author}), "utf8 decoded" );
51         is( length($yaml->[0]->{author}), 39, "utf8 decoded as characters" );
52 }