cvsuser 02/05/21 06:46:18
Modified: P5EEx/Blue/t Config.t Reference.t
Log:
updated to use Test::More
Revision Changes Path
1.2 +26 -40 p5ee/P5EEx/Blue/t/Config.t
Index: Config.t
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/t/Config.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- Config.t 3 Jan 2002 18:55:09 -0000 1.1
+++ Config.t 21 May 2002 13:46:18 -0000 1.2
@@ -1,46 +1,32 @@
-#!/usr/local/bin/perl
-######################################################################
-## $Id: Config.t,v 1.1 2002/01/03 18:55:09 spadkins Exp $
-######################################################################
-
-@files = <examples/Config.*[0-9]>;
-foreach $file (@files) {
- push(@cmds,$file) if ($file !~ /\.out$/);
-}
-print "1..", $#cmds+1, "\n";
+#!/usr/local/bin/perl -wT
-for ($i = 0; $i <= $#cmds; $i++) {
- $cmd = $cmds[$i];
- $output = &readfile("$cmd |");
- $goodoutput = &readfile("< $cmd.out");
-
- if ($goodoutput eq "") {
- $goodoutput = $output;
- &writefile("$cmd.out",$goodoutput);
- }
+use Test::More qw(no_plan);
+use lib ".";
+use lib "..";
- if ($output eq $goodoutput) {
- print "ok\n";
- }
- else {
- print "not ok\n";
- }
+BEGIN {
+ use_ok("P5EEx::Blue::P5EE");
+ use_ok("P5EEx::Blue::Config::File");
}
-sub readfile {
- my ($file) = @_;
- if (!open(FILE,$file)) {
- return("");
- }
- my @data = <FILE>;
- close(FILE);
- return (join("", @data));
-}
+my ($conf, $config, $file, $dir);
+#$P5EEx::Blue::DEBUG = 1;
+
+$dir = ".";
+$dir = "t" if (! -f "config.pl");
+$conf = do "$dir/config.pl";
+$config = P5EEx::Blue::P5EE->config();
-sub writefile {
- my ($file,$data) = @_;
- open(FILE,"> $file") || die "Unable to open $file: $!\n";
- print FILE $data;
- close(FILE);
+ok(defined $config, "constructor ok");
+isa_ok($config, "P5EEx::Blue::Config", "right class");
+is_deeply($conf, { %$config }, "config to depth");
+
+foreach $file qw(config.pl config.xml config.ini config.properties) {
+ $config = P5EEx::Blue::Config::File->new( configFile => "$dir/$file" );
+ ok(defined $config, "$file: constructor ok");
+ isa_ok($config, "P5EEx::Blue::Config", "$file: right class");
+ is_deeply($conf, { %$config }, "$file: config to depth");
}
+
+exit 0;
1.2 +28 -41 p5ee/P5EEx/Blue/t/Reference.t
Index: Reference.t
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/t/Reference.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- Reference.t 3 Jan 2002 18:55:09 -0000 1.1
+++ Reference.t 21 May 2002 13:46:18 -0000 1.2
@@ -1,46 +1,33 @@
-#!/usr/local/bin/perl
-######################################################################
-## $Id: Reference.t,v 1.1 2002/01/03 18:55:09 spadkins Exp $
-######################################################################
-
-@files = <examples/Reference.*[0-9]>;
-foreach $file (@files) {
- push(@cmds,$file) if ($file !~ /\.out$/);
-}
-print "1..", $#cmds+1, "\n";
+#!/usr/local/bin/perl -wT
-for ($i = 0; $i <= $#cmds; $i++) {
- $cmd = $cmds[$i];
- $output = &readfile("$cmd |");
- $goodoutput = &readfile("< $cmd.out");
-
- if ($goodoutput eq "") {
- $goodoutput = $output;
- &writefile("$cmd.out",$goodoutput);
- }
+use Test::More qw(no_plan);
+use lib ".";
+use lib "..";
- if ($output eq $goodoutput) {
- print "ok\n";
- }
- else {
- print "not ok\n";
- }
+BEGIN {
+ use_ok("P5EEx::Blue::Reference");
}
-sub readfile {
- my ($file) = @_;
- if (!open(FILE,$file)) {
- return("");
- }
- my @data = <FILE>;
- close(FILE);
- return (join("", @data));
-}
+use strict;
-sub writefile {
- my ($file,$data) = @_;
- open(FILE,"> $file") || die "Unable to open $file: $!\n";
- print FILE $data;
- close(FILE);
-}
+#$P5EEx::Blue::DEBUG = 0;
+my ($ref, $branch);
+
+$ref = P5EEx::Blue::Reference->new();
+ok(defined $ref, "constructor ok");
+isa_ok($ref, "P5EEx::Blue::Reference", "right class");
+
+$ref->set("x.y.z.pi", 3.1416);
+is($ref->get("x.y.z.pi"), 3.1416, "get x.y.z.pi");
+
+$branch = $ref->get_branch("x.y.z");
+is($branch->{pi}, 3.1416, "get_branch()");
+
+$branch = $ref->get_branch("zeta.alpha");
+ok(! defined $branch, "non-existent branch");
+
+$branch = $ref->get_branch("zeta.alpha", 1);
+ok(defined $branch, "newly existent branch");
+
+exit 0;