From afc1678d5d1ae96245da0afa7e77464e08594193 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 19 Oct 2009 19:45:20 +0000 Subject: [PATCH] - git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@72 be1acefe-a474-0410-9a34-9b3221f2030f --- t/PathObject.pm | 24 ++++++++++++++++++++++++ t/run.t | 14 +++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 t/PathObject.pm diff --git a/t/PathObject.pm b/t/PathObject.pm new file mode 100644 index 0000000..f73f978 --- /dev/null +++ b/t/PathObject.pm @@ -0,0 +1,24 @@ +# +# Pathobject fake module to test Config::General +# without the need to install Path::Class::File module. +# +# Submitted by Matt S Trout, Copyright (c) 2009 Matt S Trout. + + +package PathObject; + +use overload ('""' => 'stringify'); + +sub new { + my $class = shift; + my $self = {}; + bless $self, $class; + return $self; +} + +sub stringify { + my ($self) = @_; + return "t/test.rc"; +} + +1; diff --git a/t/run.t b/t/run.t index fc86735..47f447e 100644 --- a/t/run.t +++ b/t/run.t @@ -8,7 +8,7 @@ use Data::Dumper; -use Test::More tests => 51; +use Test::More tests => 53; #use Test::More qw(no_plan); # ahem, we deliver the test code with a local copy of @@ -650,3 +650,15 @@ my $cfg48 = new Config::General( %hash48 = $cfg48->getall(); my $str48 = $cfg48->save_string(\%hash48); is( $str48, $ostr48, "tied hash test"); + + +# Check whether we can create a C::G object when -ConfigFile is passed as a stringify-able object. +use PathObject; +my $cfgFileObject = new PathObject; +my $cfg49 = new Config::General( + -ConfigFile => $cfgFileObject, + -ExtendedAccess => 1 + ); +ok($cfg49, "Creating a new object using the stringify-able file object way"); +my $domain49 = $cfg49->keys("domain"); +ok($domain49, "Config object created using the stringify-able file object way contains the domain section.");