From 6aed1eca976c3eec6b971f18a74943c8e5274d2e Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Wed, 26 Apr 2017 23:16:48 +0200
Subject: Update tests
---
t/01-read.t | 18 ++++++++++++++++++
t/02-merge.t | 22 ++++++++++++++++++++++
t/files/config.yaml | 3 +++
t/files/merge.yaml | 0
t/read.t | 18 ------------------
t/test.yaml | 3 ---
6 files changed, 43 insertions(+), 21 deletions(-)
create mode 100644 t/01-read.t
create mode 100644 t/02-merge.t
create mode 100644 t/files/config.yaml
create mode 100644 t/files/merge.yaml
delete mode 100644 t/read.t
delete mode 100644 t/test.yaml
diff --git a/t/01-read.t b/t/01-read.t
new file mode 100644
index 0000000..9888ad7
--- /dev/null
+++ b/t/01-read.t
@@ -0,0 +1,18 @@
+#! /usr/bin/env perl6
+
+use v6.c;
+use Test;
+use lib "lib";
+
+use Config;
+
+plan 5;
+
+my $config = Config.new();
+
+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";
+ok $config.get("nonexistant") === Nil, "Get nonexistant key";
+ok $config.get("nonexistant", "test") === "test", "Get nonexistant key with default";
diff --git a/t/02-merge.t b/t/02-merge.t
new file mode 100644
index 0000000..8018e73
--- /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"
+ }
+}
diff --git a/t/files/config.yaml b/t/files/config.yaml
new file mode 100644
index 0000000..2b93ee8
--- /dev/null
+++ b/t/files/config.yaml
@@ -0,0 +1,3 @@
+a: a
+b:
+ c: c
diff --git a/t/files/merge.yaml b/t/files/merge.yaml
new file mode 100644
index 0000000..e69de29
diff --git a/t/read.t b/t/read.t
deleted file mode 100644
index 7a2c0f7..0000000
--- a/t/read.t
+++ /dev/null
@@ -1,18 +0,0 @@
-#! /usr/bin/env perl6
-
-use v6.c;
-use Test;
-use lib "lib";
-
-use Config;
-
-plan 5;
-
-my $config = Config.new();
-
-ok $config.read("t/test.yaml"), "Read a YAML file";
-
-ok $config.get("a") eq "a", "Get simple key";
-ok $config.get("b.c") eq "c", "Get nested key";
-ok $config.get("nonexistant") === Nil, "Get nonexistant key";
-ok $config.get("nonexistant", "test") === "test", "Get nonexistant key with default";
diff --git a/t/test.yaml b/t/test.yaml
deleted file mode 100644
index 2b93ee8..0000000
--- a/t/test.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-a: a
-b:
- c: c
--
cgit v1.1
From 10a43069bef7746c3970c6a00e8ef555c53b8c5c Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Wed, 26 Apr 2017 23:44:37 +0200
Subject: Fix up test
---
lib/Config/Parser/yaml.pm6 | 1 +
t/02-merge.t | 2 +-
t/files/merge.yaml | 2 ++
3 files changed, 4 insertions(+), 1 deletion(-)
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);
}
}
diff --git a/t/02-merge.t b/t/02-merge.t
index 8018e73..cf9aa6a 100644
--- a/t/02-merge.t
+++ b/t/02-merge.t
@@ -19,4 +19,4 @@ is-deeply $config.get(), {
c => "c",
d => "d"
}
-}
+}, "Ensure configurations are merged";
diff --git a/t/files/merge.yaml b/t/files/merge.yaml
index e69de29..64ce87b 100644
--- a/t/files/merge.yaml
+++ b/t/files/merge.yaml
@@ -0,0 +1,2 @@
+b:
+ d: "d"
--
cgit v1.1