aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPatrick Spek <Tyil@users.noreply.github.com>2017-04-26 09:57:40 +0200
committerGitHub <noreply@github.com>2017-04-26 09:57:39 +0200
commit845c2d891e12b7abe006aa1e36c1201266b29a51 (patch)
tree0ebf21647bd4bcea5b71a493302bea264a4f87e5 /t
parentacdac7ea2f81e739c7e2b5cb37d3f3cdc71962a8 (diff)
parent7313624f98295bb80416009cf21012cec10bdc15 (diff)
Merge pull request #2 from scriptkitties/with-hash-mergev1.1.0
Merge hashes instead of overwriting them
Diffstat (limited to 't')
-rw-r--r--t/having.t4
-rw-r--r--t/reading.t27
-rw-r--r--t/setting.t4
3 files changed, 32 insertions, 3 deletions
diff --git a/t/having.t b/t/having.t
index 3be2935..0627ed5 100644
--- a/t/having.t
+++ b/t/having.t
@@ -4,7 +4,7 @@ use v6.c;
use Test;
use lib "lib";
-plan 2;
+plan 4;
use Config;
@@ -19,3 +19,5 @@ $config.read({
ok $config.has("a"), "Check existence of simple key";
ok $config.has("b.c"), "Check existence of nested key";
+ok $config.has(["a"]), "Check existence of simple key using array";
+ok $config.has(["b", "c"]), "Check existence of nested key using array";
diff --git a/t/reading.t b/t/reading.t
index 52859af..e43252a 100644
--- a/t/reading.t
+++ b/t/reading.t
@@ -4,7 +4,7 @@ use v6.c;
use Test;
use lib "lib";
-plan 3;
+plan 5;
use Config;
@@ -13,3 +13,28 @@ my $config = Config.new();
throws-like { $config.read("nonexistant-config") }, Config::Exception::FileNotFoundException, "Reading nonexisting file";
throws-like { $config.read("t/test-stub") }, Config::Exception::UnknownTypeException, "Reading file of unknown type";
throws-like { $config.read("t/test-stub", "Config::Parser:NoSuchParserForTest") }, Config::Exception::MissingParserException, "Using non-existing parser";
+
+my $hash = {
+ "a" => "a",
+ "b" => {
+ "c" => "test"
+ }
+};
+
+$config.read($hash);
+
+is-deeply $config.get(), $hash, "Correctly sets hash";
+
+$config.read({
+ "b" => {
+ "d" => "another"
+ }
+});
+
+is-deeply $config.get(), {
+ "a" => "a",
+ "b" => {
+ "c" => "test",
+ "d" => "another"
+ }
+}, "Correctly merges new hash into existing config";
diff --git a/t/setting.t b/t/setting.t
index d9f0854..7e3a457 100644
--- a/t/setting.t
+++ b/t/setting.t
@@ -4,7 +4,7 @@ use v6.c;
use Test;
use lib "lib";
-plan 2;
+plan 4;
use Config;
@@ -12,3 +12,5 @@ my $config = Config.new();
ok $config.set("a", "test").get("a") eq "test", "Setting simple key";
ok $config.set("b.c", "test").get("b.c") eq "test", "Setting nested key";
+ok $config.set(["d"], "test").get("d") eq "test", "Setting simple key using array";
+ok $config.set(["e", "f"], "test").get("e.f") eq "test", "Setting nested key using array";