1 #!/usr/local/bin/perl -w
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
7 use_ok 'Module::Build::YAML';
8 ensure_blib('Module::Build::YAML');
12 $dir = "t" if (-d "t");
15 my ($expected, $got, $var);
16 ##########################################################
17 # Test a typical-looking Module::Build structure (alphabetized)
18 ##########################################################
21 'license' => 'http://opensource.org/licenses/artistic-license.php'
25 'url' => 'http://module-build.sourceforge.net/META-spec-v1.2.html'
27 'generated_by' => 'Module::Build version 0.2709',
30 'dynamic_config' => '1',
32 '"Stephen Adkins" <spadkins@gmail.com>'
38 'Module::Build' => '0'
41 'JavaScript::App' => {
43 'file' => 'lib/JavaScript/App.pm'
49 'abstract' => 'A framework for building dynamic widgets or full applications in Javascript'
53 abstract: A framework for building dynamic widgets or full applications in Javascript
55 - '"Stephen Adkins" <spadkins@gmail.com>'
61 generated_by: Module::Build version 0.2709
64 url: http://module-build.sourceforge.net/META-spec-v1.2.html
69 file: lib/JavaScript/App.pm
74 license: http://opensource.org/licenses/artistic-license.php
77 $got = &Module::Build::YAML::Dump($var);
78 is($got, $expected, "Dump(): single deep hash");
80 ##########################################################
81 # Test a typical-looking Module::Build structure (ordered)
82 ##########################################################
88 - '"Stephen Adkins" <spadkins@gmail.com>'
89 abstract: A framework for building dynamic widgets or full applications in Javascript
92 license: http://opensource.org/licenses/artistic-license.php
102 file: lib/JavaScript/App.pm
104 generated_by: Module::Build version 0.2709
106 url: http://module-build.sourceforge.net/META-spec-v1.2.html
109 $var->{_order} = [qw(name version author abstract license resources requires build_requires dynamic_config provides)];
110 $got = &Module::Build::YAML::Dump($var);
111 is($got, $expected, "Dump(): single deep hash, ordered");
113 ##########################################################
114 # Test that an array turns into multiple documents
115 ##########################################################
119 [ "pi", "is", 3.1416 ],
120 { fun => "under_sun", 6 => undef, "more", undef },
136 $got = &Module::Build::YAML::Dump(@$var);
137 is($got, $expected, "Dump(): multiple, various");
139 ##########################################################
140 # Test that a single array ref turns into one document
141 ##########################################################
155 $got = &Module::Build::YAML::Dump($var);
156 is($got, $expected, "Dump(): single array of various");
158 ##########################################################
159 # Test Object-Oriented Flavor of the API
160 ##########################################################
161 my $y = Module::Build::YAML->new();
162 $got = $y->Dump($var);
163 is($got, $expected, "Dump(): single array of various (OO)");
165 ##########################################################
166 # Test Quoting Conditions (newlines, quotes, tildas, undefs)
167 ##########################################################
169 'foo01' => '`~!@#$%^&*()_+-={}|[]\\;\':",./?<>
171 'foo02' => '~!@#$%^&*()_+-={}|[]\\;:,./<>?',
177 foo01: "`~!@#$%^&*()_+-={}|[]\;':\",./?<>\n<nl>"
178 foo02: "~!@#$%^&*()_+-={}|[]\;:,./<>?"
182 $got = &Module::Build::YAML::Dump($var);
183 is($got, $expected, "Dump(): tricky embedded characters");
257 $got = &Module::Build::YAML::Dump($var);
258 is($got, $expected, "Dump(): tricky embedded characters (singles)");