Files
Config-General/t/run.t

224 lines
4.7 KiB
Perl
Raw Normal View History

# -*-perl-*-
# testscript for Config::General Classes by Thomas Linden
#
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
# needs to be invoked using the command "make test" from
# the Config::General source directory.
#
# Under normal circumstances every test should succeed.
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
BEGIN { $| = 1; print "1..19\n";}
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
use lib "blib/lib";
use Config::General;
use Data::Dumper;
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
print "ok\n";
print STDERR " .. ok # loading Config::General\n";
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
foreach (2..7) {
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
&p("t/cfg." . $_, $_);
}
my $conf = new Config::General("t/cfg.8");
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
my %hash = $conf->getall;
$conf->save_file("t/cfg.out");
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
my $copy = new Config::General("t/cfg.out");
my %copyhash = $copy->getall;
my $a = \%hash;
my $b = \%copyhash;
# now see if the saved hash is still the same as the
# one we got from cfg.8
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
if (&comp($a,$b)) {
print "ok\n";
print STDERR " .. ok # Writing Config Hash to disk and compare with original\n";
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
}
else {
print "8 not ok\n";
print STDERR "8 .. not ok\n";
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
}
############## Extended Tests #################
$conf = new Config::General(
-ExtendedAccess => 1,
-ConfigFile => "t/test.rc");
print "ok\n";
print STDERR " .. ok # Creating a new object from config file\n";
# now test the new notation of new()
my $conf2 = new Config::General(
-ExtendedAccess => 1,
-ConfigFile => "t/test.rc",
-AllowMultiOptions => "yes"
);
print "ok\n";
print STDERR " .. ok # Creating a new object using the hash parameter way\n";
my $domain = $conf->obj("domain");
print "ok\n";
print STDERR " .. ok # Creating a new object from a block\n";
my $addr = $domain->obj("bar.de");
print "ok\n";
print STDERR " .. ok # Creating a new object from a sub block\n";
my @keys = $conf->keys("domain");
print "ok\n";
print STDERR " .. ok # Getting values from the object\n";
# test various OO methods
if ($conf->is_hash("domain")) {
my $domains = $conf->obj("domain");
foreach my $domain ($conf->keys("domain")) {
my $domain_obj = $domains->obj($domain);
foreach my $address ($domains->keys($domain)) {
my $blah = $domain_obj->value($address);
}
}
}
print "ok\n";
print STDERR " .. ok # Using keys() and values() \n";
# test AUTOLOAD methods
my $conf3 = new Config::General(
-ExtendedAccess => 1,
-ConfigHash => { name => "Moser", prename => "Hannes"}
);
my $n = $conf3->name;
my $p = $conf3->prename;
$conf3->name("Meier");
$conf3->prename("Max");
$conf3->save_file("t/test.cfg");
print "ok\n";
print STDERR " .. ok # Using AUTOLOAD methods\n";
# testing variable interpolation
my $conf16 = new Config::General(-ConfigFile => "t/cfg.16", -InterPolateVars => 1, -StrictVars => 0);
my %h16 = $conf16->getall();
if($h16{etc}->{log} eq "/usr/local/log/logfile") {
print "ok\n";
print STDERR " .. ok # Testing variable interpolation\n";
}
else {
print "16 not ok\n";
print STDERR "16 not ok\n";
}
# testing value pre-setting using a hash
my $conf17 = new Config::General(
-file => "t/cfg.17",
-DefaultConfig => { home => "/exports/home", logs => "/var/backlog" },
-MergeDuplicateOptions => 1,
-MergeDuplicateBlocks => 1
);
my %h17 = $conf17->getall();
if ($h17{home} eq "/home/users") {
print "ok\n";
print STDERR " .. ok # Testing value pre-setting using a hash\n";
}
else {
print "17 not ok\n";
print STDERR "17 not ok\n";
}
# testing value pre-setting using a string
my $conf18 = new Config::General(
-file => "t/cfg.17", # reuse the file
-DefaultConfig => "home = /exports/home\nlogs = /var/backlog",
-MergeDuplicateOptions => 1,
-MergeDuplicateBlocks => 1
);
my %h18 = $conf18->getall();
if ($h18{home} eq "/home/users") {
print "ok\n";
print STDERR " .. ok # Testing value pre-setting using a string\n";
}
else {
print "18 not ok\n";
print STDERR "18 not ok\n";
}
# testing various otion/value assignemnt notations
my $conf19 = new Config::General(-file => "t/cfg.19");
my %h19 = $conf19->getall();
my $works = 1;
foreach my $key (keys %h19) {
if ($key =~ /\s/) {
$works = 0;
}
}
if ($works) {
print "ok\n";
print STDERR " .. ok # Testing various otion/value assignemnt notations\n";
}
else {
print "19 not ok\n";
print STDERR "19 not ok\n";
}
# all subs here
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
sub p {
my($cfg, $t) = @_;
open T, "<$cfg";
my @file = <T>;
close T;
@file = map { chomp($_); $_} @file;
my $fst = $file[0];
my $conf = new Config::General($cfg);
my %hash = $conf->getall;
print "ok\n";
print STDERR " .. ok $fst\n";
revision 1.16 date: 2000/08/03 16:54:58; author: jens; state: Exp; lines: +4 -1 An jedes File eine Sektion # Local Variables: *** # perl-master-file: ../../webmin/index.pl *** # End: *** rangehängt, damit ich mit C-c d das debugging von jedem File aus einschalten kann (siehe mein .emacs file) ---------------------------- revision 1.15 date: 2000/08/01 09:12:52; author: tom; state: Exp; lines: +57 -68 added comments to _open() and _parse() ---------------------------- revision 1.14 date: 2000/07/31 18:07:12; author: tom; state: Exp; lines: +44 -19 added <<include ... >> capability ---------------------------- revision 1.13 date: 2000/07/16 18:35:33; author: tom; state: Exp; lines: +135 -10 added here-doc and multi-line feature, updated perlpod ---------------------------- revision 1.12 date: 2000/07/14 14:56:09; author: tom; state: Exp; lines: +2 -2 bug fixed, it did not ignore options inside c-comments with a # comment @ the end of line ---------------------------- revision 1.11 date: 2000/07/14 11:26:04; author: tom; state: Exp; lines: +42 -6 added C-Style comments and allow also comments after a statement. ---------------------------- revision 1.10 date: 2000/07/12 14:04:51; author: tom; state: Exp; lines: +2 -1 i woas ned ---------------------------- revision 1.9 date: 2000/07/12 10:59:53; author: jens; state: Exp; lines: +5 -3 hehe :) ---------------------------- revision 1.8 date: 2000/07/12 10:43:20; author: tom; state: Exp; lines: +5 -2 fixed bug in getall(), which doubled %config if called more than onse. ---------------------------- revision 1.7 date: 2000/07/12 09:09:33; author: tom; state: Exp; lines: +22 -24 100% Apache Config complete ;-) it supports now "named blocks"! ---------------------------- revision 1.6 date: 2000/07/11 23:43:03; author: tom; state: Exp; lines: +72 -19 added named block support (<server holland>) ---------------------------- revision 1.5 date: 2000/07/11 20:49:47; author: tom; state: Exp; lines: +2 -2 typo in pod corrected ---------------------------- revision 1.4 date: 2000/07/11 17:07:04; author: tom; state: Exp; lines: +61 -7 a config file can now contain an option more than once and will be returned as array ---------------------------- revision 1.3 date: 2000/07/07 11:27:38; author: cvs; state: Exp; lines: +2 -2 folgende Parameterform geht jetzt auch: parameter= blabla vorher musste man parameter = blabla schreiben ---------------------------- revision 1.2 date: 2000/07/04 13:21:12; author: tom; state: Exp; lines: +9 -4 added better failurehandling in case of missing block start/end statements ---------------------------- revision 1.1 date: 2000/07/04 12:52:09; author: tom; state: Exp; implemented module and method getall, works as expected. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@5 be1acefe-a474-0410-9a34-9b3221f2030f
2009-10-10 16:07:21 +00:00
}
sub comp {
my($a, $b) = @_;
foreach my $key (keys %{$a}) {
if(ref($a->{$key}) eq "HASH") {
&comp($a->{$key},$b->{$key});
next;
}
elsif(ref($a->{$key}) eq "ARRAY") {
# ignore arrays for simplicity
next;
}
return 0 if($a->{$key} ne $b->{$key});
}
return 1;
}