Skip to content
Browse files

Use test::differences, multiple resources in the same block

  • Loading branch information...
1 parent 1c45ab5 commit 4a6674de671aa1ecc8703cca069bbeea61126335 @bobtfish committed Oct 29, 2011
Showing with 29 additions and 14 deletions.
  1. +4 −0 Makefile.PL
  2. +7 −4 share/puppet.pgx
  3. +18 −10 t/basic.t
View
4 Makefile.PL
@@ -6,5 +6,9 @@ all_from 'lib/Pegex/Puppet.pm';
requires 'boolean';
requires 'Pegex' => '0.18';
+
+test_requires 'Test::More' => '0.88';
+test_requires 'Test::Differences' => '0';
+
WriteAll;
View
11 share/puppet.pgx
@@ -6,10 +6,7 @@ resource:
<resource_type>
/~<LCURLY>~/
<wspace>
- <resource_name>
- <wspace>
- <set_of_resource_terms>*
- <wspace>
+ <resource_definition>*
/<RCURLY>/
<wspace>
@@ -19,6 +16,12 @@ quoted_string: /"([<SLASH>\w\s]+)"/
resource_type: /(\w+(?:<COLON><COLON>\w+)*)/
+resource_definition:
+ <resource_name>
+ <wspace>
+ <set_of_resource_terms>*
+ <wspace>
+
resource_name: <bare_resource_name> | <quoted_resource_name>
bare_resource_name: <bare_word> /:/
View
28 t/basic.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use Test::More 0.88;
-use Data::Dumper;
+use Test::Differences;
use Pegex::Puppet;
@@ -10,37 +10,45 @@ my @data = (
foo:
foo => bar
}
-} => [['file', ['foo'], [[[foo => 'bar']]]]]],
+} => [['file', [[['foo'], [[[foo => 'bar']]]]]]]],
[q{file {
"/tmp/foo":
ensure => exists
}
-} => [['file', ['/tmp/foo'], [[[ensure => 'exists']]]]]],
+} => [['file', [[['/tmp/foo'], [[[ensure => 'exists']]]]]]]],
[q{file {
"/tmp/foo":
content => "foo"
}
-} => [['file', ['/tmp/foo'], [[[content => 'foo']]]]]],
+} => [['file', [[['/tmp/foo'], [[[content => 'foo']]]]]]]],
[q{file::mine {
"/tmp/foo":
content => "foo"
}
-} => [['file::mine', ['/tmp/foo'], [[[content => 'foo']]]]]],
+} => [['file::mine', [[['/tmp/foo'], [[[content => 'foo']]]]]]]],
[q{file::mine {
"/tmp/foo":
- content => "foo"
- ensure => exists
+ content => "foo",
+ ensure => exists;
+}
+} => [['file::mine', [[['/tmp/foo'], [[[content => 'foo']], [[ensure => 'exists']]]]]]]],
+[q{file::mine {
+ "/tmp/foo":
+ content => "foo",
+ ensure => exists;
+ "/tmp/blaaa":
+ content => "blaa",
+ ensure => exists;
}
-} => [['file::mine', ['/tmp/foo'], [[[content => 'foo']], [[ensure => 'exists']]]]]],
+} => [['file::mine', [[['/tmp/foo'], [[[content => 'foo']], [[ensure => 'exists']]]], [['/tmp/blaaa'], [[[content => 'blaa']], [[ensure => 'exists']]]]]]]],
);
foreach my $thing (@data) {
my ($doc, $exp) = @$thing;
my $data = Pegex::Puppet->parse($doc);
- is_deeply($data, $exp)
- or diag "Got: " . Dumper($data) . "\nExpected: " . Dumper($exp);
+ eq_or_diff($data, $exp);
}
done_testing;

0 comments on commit 4a6674d

Please sign in to comment.
Something went wrong with that request. Please try again.