From c2b980b7962951bc5c277473d41974e76a5e66fa Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 23:10:00 +0200 Subject: Rename test files --- t/01-reading.t | 40 ++++++++++++++++++++++++++++++++++++++++ t/02-getting.t | 28 ++++++++++++++++++++++++++++ t/03-having.t | 23 +++++++++++++++++++++++ t/04-setting.t | 16 ++++++++++++++++ t/getting.t | 28 ---------------------------- t/having.t | 23 ----------------------- t/reading.t | 40 ---------------------------------------- t/setting.t | 16 ---------------- 8 files changed, 107 insertions(+), 107 deletions(-) create mode 100644 t/01-reading.t create mode 100644 t/02-getting.t create mode 100644 t/03-having.t create mode 100644 t/04-setting.t delete mode 100644 t/getting.t delete mode 100644 t/having.t delete mode 100644 t/reading.t delete mode 100644 t/setting.t (limited to 't') diff --git a/t/01-reading.t b/t/01-reading.t new file mode 100644 index 0000000..0792188 --- /dev/null +++ b/t/01-reading.t @@ -0,0 +1,40 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +plan 5; + +use Config; + +my $config = Config.new(); + +throws-like { $config.read("t/files/none") }, Config::Exception::FileNotFoundException, "Reading nonexisting file"; +throws-like { $config.read("t/files/config") }, Config::Exception::UnknownTypeException, "Reading file of unknown type"; +throws-like { $config.read("t/files/config", "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/02-getting.t b/t/02-getting.t new file mode 100644 index 0000000..06a345a --- /dev/null +++ b/t/02-getting.t @@ -0,0 +1,28 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +plan 8; + +use Config; + +my $config = Config.new(); + +$config.read({ + a => "a", + b => { + c => "c" + } +}); + +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"; + +ok $config.get(["a"]) eq "a", "Get simple key by array"; +ok $config.get(["b", "c"]) eq "c", "Get nested key by array"; +ok $config.get(["nonexistant"]) === Nil, "Get nonexistant key by array"; +ok $config.get(["nonexistant"], "test") === "test", "Get nonexistant key by array with default"; diff --git a/t/03-having.t b/t/03-having.t new file mode 100644 index 0000000..0627ed5 --- /dev/null +++ b/t/03-having.t @@ -0,0 +1,23 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +plan 4; + +use Config; + +my $config = Config.new(); + +$config.read({ + a => "a", + b => { + c => "c" + } +}); + +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/04-setting.t b/t/04-setting.t new file mode 100644 index 0000000..7e3a457 --- /dev/null +++ b/t/04-setting.t @@ -0,0 +1,16 @@ +#! /usr/bin/env perl6 + +use v6.c; +use Test; +use lib "lib"; + +plan 4; + +use Config; + +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"; diff --git a/t/getting.t b/t/getting.t deleted file mode 100644 index 06a345a..0000000 --- a/t/getting.t +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env perl6 - -use v6.c; -use Test; -use lib "lib"; - -plan 8; - -use Config; - -my $config = Config.new(); - -$config.read({ - a => "a", - b => { - c => "c" - } -}); - -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"; - -ok $config.get(["a"]) eq "a", "Get simple key by array"; -ok $config.get(["b", "c"]) eq "c", "Get nested key by array"; -ok $config.get(["nonexistant"]) === Nil, "Get nonexistant key by array"; -ok $config.get(["nonexistant"], "test") === "test", "Get nonexistant key by array with default"; diff --git a/t/having.t b/t/having.t deleted file mode 100644 index 0627ed5..0000000 --- a/t/having.t +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env perl6 - -use v6.c; -use Test; -use lib "lib"; - -plan 4; - -use Config; - -my $config = Config.new(); - -$config.read({ - a => "a", - b => { - c => "c" - } -}); - -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 deleted file mode 100644 index 0792188..0000000 --- a/t/reading.t +++ /dev/null @@ -1,40 +0,0 @@ -#! /usr/bin/env perl6 - -use v6.c; -use Test; -use lib "lib"; - -plan 5; - -use Config; - -my $config = Config.new(); - -throws-like { $config.read("t/files/none") }, Config::Exception::FileNotFoundException, "Reading nonexisting file"; -throws-like { $config.read("t/files/config") }, Config::Exception::UnknownTypeException, "Reading file of unknown type"; -throws-like { $config.read("t/files/config", "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 deleted file mode 100644 index 7e3a457..0000000 --- a/t/setting.t +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env perl6 - -use v6.c; -use Test; -use lib "lib"; - -plan 4; - -use Config; - -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