diff options
author | Patrick Spek <Tyil@users.noreply.github.com> | 2017-04-26 23:54:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 23:54:32 +0200 |
commit | 5127bb559bad6e25bd53eb07cb9aefc538714985 (patch) | |
tree | 80c8916c7bc239f71c422780bbf549f9ac9afa29 | |
parent | c1dc65009e381ab09f15bb73529491d427d77232 (diff) | |
parent | 10a43069bef7746c3970c6a00e8ef555c53b8c5c (diff) | |
download | config-parser-yaml-5127bb559bad6e25bd53eb07cb9aefc538714985.tar.gz config-parser-yaml-5127bb559bad6e25bd53eb07cb9aefc538714985.tar.bz2 |
Merge pull request #1 from scriptkitties/merge-test
Add test for array merging
-rw-r--r-- | lib/Config/Parser/yaml.pm6 | 1 | ||||
-rw-r--r-- | t/01-read.t (renamed from t/read.t) | 2 | ||||
-rw-r--r-- | t/02-merge.t | 22 | ||||
-rw-r--r-- | t/files/config.yaml (renamed from t/test.yaml) | 0 | ||||
-rw-r--r-- | t/files/merge.yaml | 2 |
5 files changed, 26 insertions, 1 deletions
diff --git a/lib/Config/Parser/yaml.pm6 b/lib/Config/Parser/yaml.pm6 index c0c194e..366368f 100644 --- a/lib/Config/Parser/yaml.pm6 +++ b/lib/Config/Parser/yaml.pm6 @@ -9,6 +9,7 @@ class Config::Parser::yaml is Config::Parser { method read(Str $path --> Hash) { + say $path; load-yaml(slurp $path); } } @@ -10,7 +10,7 @@ plan 5; my $config = Config.new(); -ok $config.read("t/test.yaml"), "Read a YAML file"; +ok $config.read("t/files/config.yaml"), "Read a YAML file"; ok $config.get("a") eq "a", "Get simple key"; ok $config.get("b.c") eq "c", "Get nested key"; diff --git a/t/02-merge.t b/t/02-merge.t new file mode 100644 index 0000000..cf9aa6a --- /dev/null +++ b/t/02-merge.t @@ -0,0 +1,22 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +use Config; + +plan 3; + +my $config = Config.new(); + +ok $config.read("t/files/config.yaml"), "Read initial config"; +ok $config.read("t/files/merge.yaml"), "Read merge config"; + +is-deeply $config.get(), { + a => "a", + b => { + c => "c", + d => "d" + } +}, "Ensure configurations are merged"; diff --git a/t/test.yaml b/t/files/config.yaml index 2b93ee8..2b93ee8 100644 --- a/t/test.yaml +++ b/t/files/config.yaml diff --git a/t/files/merge.yaml b/t/files/merge.yaml new file mode 100644 index 0000000..64ce87b --- /dev/null +++ b/t/files/merge.yaml @@ -0,0 +1,2 @@ +b: + d: "d" |