Skip to content

Commit

Permalink
pod and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kawanet committed Apr 24, 2012
1 parent 3aab88f commit 9c3a222
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 0 deletions.
23 changes: 23 additions & 0 deletions MANIFEST
@@ -0,0 +1,23 @@
MANIFEST
META.yml
Makefile.PL
README
lib/Config/Pico.pm
t/00_compile.t
t/01_basic.t
t/02_pico.t
t/03_strict.t
t/04_notfound.t
t/config/array.pl
t/config/arrayref.pl
t/config/hashref.pl
t/config/nostrict.pl
t/config/one.pl
t/config/plusarray.pl
t/config/plusarrayref.pl
t/config/plushashref.pl
t/config/string.pl
t/config/two.pl
t/config/undef.pl
t/config/usestrict.pl
t/config/zero.pl
21 changes: 21 additions & 0 deletions META.yml
@@ -0,0 +1,21 @@
--- #YAML:1.0
name: Config-Pico
version: 0.01
abstract: Perl Interpretative COnfiguration: do "config.pl"
author:
- Yusuke Kawasaki
license: perl
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 6.55
build_requires:
Test::More: 0
requires: {}
no_index:
directory:
- t
- inc
generated_by: ExtUtils::MakeMaker version 6.56
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
17 changes: 17 additions & 0 deletions t/01_basic.t
@@ -0,0 +1,17 @@
use strict;
use warnings;
use Test::More tests => 5;

BEGIN { use_ok 'Config::Pico' }

my $a = do "t/config/string.pl";
is($a, 'foobar', 'do');

my $b = pico "t/config/string.pl";
is($b, 'foobar', 'do');

my $c = pico "t/config" => "string.pl";
is($c, 'foobar', 'do');

my $d = pico("t/config", "string.pl");
is($d, 'foobar', 'do');
47 changes: 47 additions & 0 deletions t/02_pico.t
@@ -0,0 +1,47 @@
use strict;
use warnings;
use Test::More tests => 19;

BEGIN { use_ok 'Config::Pico' }

my $dir = 't/config';

my $string = pico($dir, "string.pl");
is($string, 'foobar', 'string');

my $one = pico($dir, "one.pl");
is($one, '1', 'one');

my $two = pico($dir, "two.pl");
is($two, '2', 'two');

my $zero = pico($dir, "zero.pl");
is($zero, '0', 'zero');

my $undef = pico($dir, "undef.pl");
ok(! defined $undef, 'undef');

my @array = pico($dir, "array.pl");
is($array[0], 'foo', 'array-0');
is($array[1], 'bar', 'array-1');

my @plusarray = pico($dir, "plusarray.pl");
is($plusarray[0], 'foo', 'plusarray-0');
is($plusarray[1], 'bar', 'plusarray-1');

my $arrayref = pico($dir, "arrayref.pl");
ok(ref $arrayref, 'arrayref');
is($arrayref->[0], 'foo', 'arrayref-0');
is($arrayref->[1], 'bar', 'arrayref-1');

my $plusarrayref = pico($dir, "plusarrayref.pl");
is($plusarrayref->[0], 'foo', 'plusarrayref-0');
is($plusarrayref->[1], 'bar', 'plusarrayref-1');

my $hashref = pico($dir, "hashref.pl");
ok(ref $hashref, 'hashref');
is($hashref->{foo}, 'bar', 'hashref-foo');

my $plushashref = pico($dir, "plushashref.pl");
ok(ref $plushashref, 'plushashref');
is($plushashref->{foo}, 'bar', 'plushashref-foo');
24 changes: 24 additions & 0 deletions t/03_strict.t
@@ -0,0 +1,24 @@
use strict;
use Test::More tests => 4;

BEGIN { use_ok 'Config::Pico' }

my @conf;

eval {
@conf = do "t/config/usestrict.pl";
};

ok(! $@, "do() doesn't raise error");

eval {
@conf = pico "t/config/usestrict.pl";
};

ok($@, "pico() raises error");

eval {
@conf = pico "t/config/nostrict.pl";
};

ok(! $@, "pico() doesn't raise error without 'use strict'");
18 changes: 18 additions & 0 deletions t/04_notfound.t
@@ -0,0 +1,18 @@
use strict;
use Test::More tests => 3;

BEGIN { use_ok 'Config::Pico' }

my @conf;

eval {
@conf = do "config/notfound.pl";
};

ok(! $@, "do() doesn't raise error");

eval {
@conf = pico "config/notfound.pl";
};

ok($@, "pico() raises error");
1 change: 1 addition & 0 deletions t/config/array.pl
@@ -0,0 +1 @@
('foo', 'bar');
1 change: 1 addition & 0 deletions t/config/arrayref.pl
@@ -0,0 +1 @@
['foo', 'bar'];
1 change: 1 addition & 0 deletions t/config/hashref.pl
@@ -0,0 +1 @@
{ foo => 'bar' };
4 changes: 4 additions & 0 deletions t/config/nostrict.pl
@@ -0,0 +1,4 @@
no strict;
no warnings;

$foo = $bar;
1 change: 1 addition & 0 deletions t/config/one.pl
@@ -0,0 +1 @@
1;
1 change: 1 addition & 0 deletions t/config/plusarray.pl
@@ -0,0 +1 @@
+('foo', 'bar');
1 change: 1 addition & 0 deletions t/config/plusarrayref.pl
@@ -0,0 +1 @@
+['foo', 'bar'];
1 change: 1 addition & 0 deletions t/config/plushashref.pl
@@ -0,0 +1 @@
+{ foo => 'bar' };
1 change: 1 addition & 0 deletions t/config/string.pl
@@ -0,0 +1 @@
'foobar';
1 change: 1 addition & 0 deletions t/config/two.pl
@@ -0,0 +1 @@
2;
1 change: 1 addition & 0 deletions t/config/undef.pl
@@ -0,0 +1 @@
undef;
3 changes: 3 additions & 0 deletions t/config/usestrict.pl
@@ -0,0 +1,3 @@
use strict;
use warnings;
$foo = $bar;
1 change: 1 addition & 0 deletions t/config/zero.pl
@@ -0,0 +1 @@
0;

0 comments on commit 9c3a222

Please sign in to comment.