-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option duplicate_keys (default 1 for now)
Default is 1 for now so that users can prepare, and will be set to 0 in the next release.
- Loading branch information
Showing
6 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Data::Dumper; | ||
use YAML::PP; | ||
use Test::Deep; | ||
|
||
my $allow = YAML::PP->new( | ||
duplicate_keys => 1, | ||
); | ||
my $forbid = YAML::PP->new( | ||
duplicate_keys => 0, | ||
); | ||
|
||
|
||
my $yaml = <<'EOM'; | ||
a: 1 | ||
b: 2 | ||
a: 3 | ||
EOM | ||
|
||
my $data = $allow->load_string($yaml); | ||
my $expected = { | ||
a => 3, | ||
b => 2, | ||
}; | ||
is_deeply($data, $expected, "Allowed duplicate keys"); | ||
|
||
|
||
$data = eval { $forbid->load_string($yaml) }; | ||
my $err = $@; | ||
like $err, qr{Duplicate key 'a'}, "Forbidden duplicate keys"; | ||
|
||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters