aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2018-08-26 13:06:38 +0200
committerPatrick Spek <p.spek@tyil.nl>2018-08-26 13:06:38 +0200
commitc183301cb6690b9cdb8f50f476d5195adc57fdb2 (patch)
treefd4fd06ed2f5e1638b1caeaaabcd37cfbb4b5ef6 /t
parent92ff6f1f4d3bb355c12cd3f30a9751d3488abc72 (diff)
Return self on .read
Diffstat (limited to 't')
-rw-r--r--t/01-reading.t51
1 files changed, 30 insertions, 21 deletions
diff --git a/t/01-reading.t b/t/01-reading.t
index 3a4388e..722d6eb 100644
--- a/t/01-reading.t
+++ b/t/01-reading.t
@@ -13,37 +13,46 @@ my Str $null-parser = "Config::Parser::NULL";
throws-like { $config.read("t/files/none") }, Config::Exception::FileNotFoundException, "Reading nonexisting file";
throws-like { $config.read("t/files/config", "Config::Parser:NoSuchParserForTest") }, Config::Exception::MissingParserException, "Using non-existing parser";
-is $config.read("t/files/none", $null-parser, skip-not-found => True), True, ".read allows for non-fatal execution with skip-not-found set";
+subtest ".read allows for non-fatal execution with skip-not-found set", {
+ plan 3;
+
+ my %old = $config.get;
+ my $result = $config.read("t/files/none", $null-parser, :skip-not-found);
-my $hash = {
+ ok $result, "Result is ok";
+ is-deeply $result.get, %old, "Config did not change";
+ isa-ok $result, Config, ".read returned a Config";
+}
+
+my %hash = %(
"a" => "a",
- "b" => {
- "c" => "test"
- }
-};
+ "b" => %(
+ "c" => "test",
+ ),
+);
-$config.read($hash);
+$config.read: %hash;
-is-deeply $config.get(), $hash, "Correctly sets hash";
+is-deeply $config.get, %hash, "Correctly sets hash";
-$config.read({
- "b" => {
- "d" => "another"
- }
-});
+$config.read: %(
+ "b" => %(
+ "d" => "another",
+ ),
+);
-is-deeply $config.get(), {
+is-deeply $config.get, %(
"a" => "a",
- "b" => {
+ "b" => %(
"c" => "test",
- "d" => "another"
- }
-}, "Correctly merges new hash into existing config";
+ "d" => "another",
+ ),
+), "Correctly merges new hash into existing config";
subtest {
plan 3;
- is $config.read(("t/files/config", "t/files/config.yaml"), $null-parser, skip-not-found => True), True, "All paths exist";
- is $config.read(("t/files/config", "t/files/none", "t/files/config.yaml"), $null-parser, skip-not-found => True), True, "At least one path exists";
- is $config.read(("t/files/none", "t/files/none.yaml"), $null-parser, skip-not-found => True), False, "No paths exist";
+ ok $config.read(("t/files/config", "t/files/config.yaml"), $null-parser, :skip-not-found), "All paths exist";
+ ok $config.read(("t/files/config", "t/files/none", "t/files/config.yaml"), $null-parser, :skip-not-found), "At least one path exists";
+ ok $config.read(("t/files/none", "t/files/none.yaml"), $null-parser, :skip-not-found), "No paths exist";
}, "Read with a List of paths";