From bb450bd96b02b48ed8b277fa0a6ca5c97037a680 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sat, 4 Jul 2020 13:46:25 +0200 Subject: Overhaul Config to 3.0.0 --- t/01-reading.t | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 't/01-reading.t') diff --git a/t/01-reading.t b/t/01-reading.t index 722d6eb..ba9bd55 100644 --- a/t/01-reading.t +++ b/t/01-reading.t @@ -1,28 +1,17 @@ -#! /usr/bin/env perl6 +#! /usr/bin/env raku -use v6.c; +use v6.d; use Test; -plan 6; +plan 4; use Config; +use Config::Parser::NULL; -my Config $config = Config.new(); -my Str $null-parser = "Config::Parser::NULL"; +my Config $config = Config.new; +my Config::Parser $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"; - -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); - - ok $result, "Result is ok"; - is-deeply $result.get, %old, "Config did not change"; - isa-ok $result, Config, ".read returned a Config"; -} +throws-like { $config.read('t/files/none'.IO) }, X::Config::FileNotFound, 'Reading nonexisting file'; my %hash = %( "a" => "a", @@ -33,9 +22,9 @@ my %hash = %( $config.read: %hash; -is-deeply $config.get, %hash, "Correctly sets hash"; +is-deeply $config.get, %hash, 'Correctly sets hash'; -$config.read: %( +$config.=read: %( "b" => %( "d" => "another", ), @@ -52,7 +41,7 @@ is-deeply $config.get, %( subtest { plan 3; - 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"; + ok $config.read(("t/files/config".IO, "t/files/config.yaml".IO), $null-parser, :skip-not-found), "All paths exist"; + ok $config.read(("t/files/config".IO, "t/files/none".IO, "t/files/config.yaml".IO), $null-parser, :skip-not-found), "At least one path exists"; + ok $config.read(("t/files/none".IO, "t/files/none.yaml".IO), $null-parser, :skip-not-found), "No paths exist"; }, "Read with a List of paths"; -- cgit v1.1