From fb014751bbcf785b4e43b9f622ab8114d496be09 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 08:17:33 +0200 Subject: Update test cases --- t/having.t | 2 ++ t/reading.t | 25 +++++++++++++++++++++++++ t/setting.t | 2 ++ 3 files changed, 29 insertions(+) (limited to 't') diff --git a/t/having.t b/t/having.t index 3be2935..7c3a67e 100644 --- a/t/having.t +++ b/t/having.t @@ -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..ec1c40b 100644 --- a/t/reading.t +++ b/t/reading.t @@ -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" => + "b" => { + "c" => "test" + } +}; + +$config.read($hash); + +is-deeply $config.get(), $hash, "Correctly sets hash"; + +$config.read({ + "b" => { + "d" => "another" + } +}) + +is-deeply $config.get(), { + "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..18790cf 100644 --- a/t/setting.t +++ b/t/setting.t @@ -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"; -- cgit v1.1 From 37c38cd5771a3aa6eb7b203f8d38ad3cc46faac8 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 08:19:53 +0200 Subject: Update test plans --- t/having.t | 2 +- t/reading.t | 2 +- t/setting.t | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/having.t b/t/having.t index 7c3a67e..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; diff --git a/t/reading.t b/t/reading.t index ec1c40b..79d2359 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; diff --git a/t/setting.t b/t/setting.t index 18790cf..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; -- cgit v1.1 From 3f4b16f712aa4b5c610319c79b7e1d7d04140503 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 08:59:30 +0200 Subject: Fix the easy bugs --- t/reading.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/reading.t b/t/reading.t index 79d2359..1c3a120 100644 --- a/t/reading.t +++ b/t/reading.t @@ -29,7 +29,7 @@ $config.read({ "b" => { "d" => "another" } -}) +}); is-deeply $config.get(), { "a" => -- cgit v1.1 From 7313624f98295bb80416009cf21012cec10bdc15 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 09:48:28 +0200 Subject: I fucked up the test --- t/reading.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/reading.t b/t/reading.t index 1c3a120..e43252a 100644 --- a/t/reading.t +++ b/t/reading.t @@ -15,7 +15,7 @@ throws-like { $config.read("t/test-stub") }, Config::Exception::UnknownTypeExcep throws-like { $config.read("t/test-stub", "Config::Parser:NoSuchParserForTest") }, Config::Exception::MissingParserException, "Using non-existing parser"; my $hash = { - "a" => + "a" => "a", "b" => { "c" => "test" } @@ -32,7 +32,7 @@ $config.read({ }); is-deeply $config.get(), { - "a" => + "a" => "a", "b" => { "c" => "test", "d" => "another" -- cgit v1.1