1 #!/usr/local/bin/perl -w
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
9 $dir = "t" if (-d "t");
12 use_ok("Module::Build::YAML");
13 my ($expected, $got, $var);
14 ##########################################################
15 # Test a typical-looking Module::Build structure (alphabetized)
16 ##########################################################
19 'license' => 'http://opensource.org/licenses/artistic-license.php'
23 'url' => 'http://module-build.sourceforge.net/META-spec-v1.2.html'
25 'generated_by' => 'Module::Build version 0.2709',
28 'dynamic_config' => '1',
30 '"Stephen Adkins" <spadkins@gmail.com>'
36 'Module::Build' => '0'
39 'JavaScript::App' => {
41 'file' => 'lib/JavaScript/App.pm'
47 'abstract' => 'A framework for building dynamic widgets or full applications in Javascript'
51 abstract: A framework for building dynamic widgets or full applications in Javascript
53 - '"Stephen Adkins" <spadkins@gmail.com>'
59 generated_by: Module::Build version 0.2709
62 url: http://module-build.sourceforge.net/META-spec-v1.2.html
67 file: lib/JavaScript/App.pm
72 license: http://opensource.org/licenses/artistic-license.php
75 $got = &Module::Build::YAML::Dump($var);
76 is($got, $expected, "Dump(): single deep hash");
78 ##########################################################
79 # Test a typical-looking Module::Build structure (ordered)
80 ##########################################################
86 - '"Stephen Adkins" <spadkins@gmail.com>'
87 abstract: A framework for building dynamic widgets or full applications in Javascript
90 license: http://opensource.org/licenses/artistic-license.php
100 file: lib/JavaScript/App.pm
102 generated_by: Module::Build version 0.2709
104 url: http://module-build.sourceforge.net/META-spec-v1.2.html
107 $var->{_order} = [qw(name version author abstract license resources requires build_requires dynamic_config provides)];
108 $got = &Module::Build::YAML::Dump($var);
109 is($got, $expected, "Dump(): single deep hash, ordered");
111 ##########################################################
112 # Test that an array turns into multiple documents
113 ##########################################################
117 [ "pi", "is", 3.1416 ],
118 { fun => "under_sun", 6 => undef, "more", undef },
134 $got = &Module::Build::YAML::Dump(@$var);
135 is($got, $expected, "Dump(): multiple, various");
137 ##########################################################
138 # Test that a single array ref turns into one document
139 ##########################################################
153 $got = &Module::Build::YAML::Dump($var);
154 is($got, $expected, "Dump(): single array of various");
156 ##########################################################
157 # Test Object-Oriented Flavor of the API
158 ##########################################################
159 my $y = Module::Build::YAML->new();
160 $got = $y->Dump($var);
161 is($got, $expected, "Dump(): single array of various (OO)");
163 ##########################################################
164 # Test Quoting Conditions (newlines, quotes, tildas, undefs)
165 ##########################################################
167 'foo01' => '`~!@#$%^&*()_+-={}|[]\\;\':",./?<>
169 'foo02' => '~!@#$%^&*()_+-={}|[]\\;:,./<>?',
175 foo01: "`~!@#$%^&*()_+-={}|[]\;':\",./?<>\n<nl>"
176 foo02: "~!@#$%^&*()_+-={}|[]\;:,./<>?"
180 $got = &Module::Build::YAML::Dump($var);
181 is($got, $expected, "Dump(): tricky embedded characters");
255 $got = &Module::Build::YAML::Dump($var);
256 is($got, $expected, "Dump(): tricky embedded characters (singles)");