This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
50b5ea113c35287e714abd5c07b529cbd7831166
[perl5.git] / cpan / CPAN-Meta-YAML / t / 20_subclass.t
1 #!/usr/bin/perl
2
3 # Testing documents that should fail
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 => 1;
14
15
16
17
18
19 #####################################################################
20 # Customized Class
21
22 SCOPE: {
23         package Foo;
24
25         use CPAN::Meta::YAML;
26
27         use vars qw{@ISA};
28         BEGIN {
29                 @ISA = 'CPAN::Meta::YAML';
30         }
31
32         sub _write_scalar {
33                 my $self   = shift;
34                 my $string = shift;
35                 my $indent = shift;
36                 if ( defined $indent ) {
37                         return "'$indent'";
38                 } else {
39                         return 'undef';
40                 }
41         }
42
43         1;
44 }
45
46
47
48
49
50 #####################################################################
51 # Generate the value
52
53 my $object = Foo->new(
54         { foo => 'bar' }
55 );
56 is( $object->write_string, "---\nfoo: '1'\n", 'Subclassing works' );