From: Chilts <and...@us...> - 2005-04-30 04:48:38
|
Update of /cvsroot/data-pluginfile/data-pluginfiles/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23090/t Modified Files: arrays.dat heredocs.dat Added Files: 00load.t 01data.t 02comments.t 03arrays.t 04heredocs.t comments.dat data.dat load.dat Removed Files: params.dat quotes.dat strings.dat Log Message: - addition of much nicer unit test (removal of old data files) - bug fix in the way an incorrect file was loaded (returns undef properly) --- NEW FILE: 04heredocs.t --- ## -------------------------------------------------------------------*-perl-*- use strict; use Test; use Data::PluginFiles; BEGIN { $| = 1; plan( tests => 7, todo => [] ); } chdir('t') if ( -d 't' ); my $data; my ($name, $params); ## ---------------------------------------------------------------------------- # Test: load the file $data = Data::PluginFiles->new('heredocs.dat'); ok($data); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(0); ok( $name, 'HereDocs1' ); ok( keys %$params, 1 ); ok( $params->{val}, "This is a 1 liner heredoc" ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(1); ok( $name, 'HereDocs2' ); ok( keys %$params, 1 ); ok( $params->{val}, "This is a\n2 liner heredoc" ); ## ---------------------------------------------------------------------------- --- NEW FILE: comments.dat --- # -*- perl -*- this is a comment Plugin: par=val --- NEW FILE: 00load.t --- ## -------------------------------------------------------------------*-perl-*- use strict; use Test; BEGIN { $| = 1; plan( tests => 3, todo => [] ); } use Data::PluginFiles; my $loaded = 1; ok($loaded); chdir('t') if ( -d 't' ); my $data; my ($name, $params); ## ---------------------------------------------------------------------------- # Test: load a simple file $data = Data::PluginFiles->new('load.dat'); ok($data); ## ---------------------------------------------------------------------------- # Test: load a random file, but shouldn't fail or warn $data = Data::PluginFiles->new('00load.t'); ok( $data, undef ); ## ---------------------------------------------------------------------------- --- params.dat DELETED --- --- NEW FILE: 01data.t --- ## -------------------------------------------------------------------*-perl-*- use strict; use Test; use Data::PluginFiles; BEGIN { $| = 1; plan( tests => 21, todo => [] ); } my $loaded = 1; ok($loaded); chdir('t') if ( -d 't' ); my $data; my ($name, $params); ## ---------------------------------------------------------------------------- # Test: load a simple file $data = Data::PluginFiles->new('data.dat'); ok($data); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(0); ok( $name, 'Simple' ); ok( keys %$params, 1 ); ok( $params->{par1}, 'val1' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(1); ok( $name, 'QuotedSingle' ); ok( keys %$params, 1 ); ok( $params->{par1}, 'val1' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(2); ok( $name, 'QuotedDouble' ); ok( keys %$params, 1 ); ok( $params->{par1}, 'val1' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(3); ok( $name, 'Escaped' ); ok( keys %$params, 1 ); ok( $params->{withspaces}, 'This is a string' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(4); ok( $name, 'Quoted' ); ok( keys %$params, 1 ); ok( $params->{withspaces}, 'This is a string' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(5); ok( $name, 'Multiple' ); ok( keys %$params, 2 ); ok( $params->{par1}, 'val1' ); ok( $params->{par2}, 'val2' ); ## ---------------------------------------------------------------------------- --- quotes.dat DELETED --- --- NEW FILE: data.dat --- Simple: par1=val1 QuotedSingle: par1='val1' QuotedDouble: par1="val1" Escaped: withspaces=This\ is\ a\ string Quoted: withspaces="This is a string" Multiple: par1=val1 par2=val2 --- NEW FILE: load.dat --- Simple: par1=val1 --- strings.dat DELETED --- --- NEW FILE: 02comments.t --- ## -------------------------------------------------------------------*-perl-*- use strict; use Test; use Data::PluginFiles; BEGIN { $| = 1; plan( tests => 4, todo => [] ); } chdir('t') if ( -d 't' ); my $data; my ($name, $params); ## ---------------------------------------------------------------------------- # Test: load a simple file $data = Data::PluginFiles->new('comments.dat'); ok($data); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(0); ok( $name, 'Plugin' ); ok( keys %$params, 1 ); ok( $params->{par}, 'val' ); ## ---------------------------------------------------------------------------- --- NEW FILE: 03arrays.t --- ## -------------------------------------------------------------------*-perl-*- use strict; use Test; use Data::PluginFiles; BEGIN { $| = 1; plan( tests => 16, todo => [] ); } chdir('t') if ( -d 't' ); my $data; my ($name, $params); ## ---------------------------------------------------------------------------- # Test: load the file $data = Data::PluginFiles->new('arrays.dat'); ok($data); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(0); ok( $name, 'Arrays1' ); ok( keys %$params, 1 ); ok( @{$params->{val}}, 3 ); ok( $params->{val}[0], 'a' ); ok( $params->{val}[1], 'b' ); ok( $params->{val}[2], 'c' ); ## ---------------------------------------------------------------------------- # Test: see what the values are ($name, $params) = $data->get_line(1); ok( $name, 'Arrays2' ); ok( keys %$params, 2 ); ok( @{$params->{par1}}, 3 ); ok( @{$params->{par2}}, 2 ); ok( $params->{par1}[0], 'a' ); ok( $params->{par1}[1], 'b' ); ok( $params->{par1}[2], 'c' ); ok( $params->{par2}[0], 'd' ); ok( $params->{par2}[1], 'e' ); ## ---------------------------------------------------------------------------- Index: heredocs.dat =================================================================== RCS file: /cvsroot/data-pluginfile/data-pluginfiles/t/heredocs.dat,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** heredocs.dat 30 Apr 2005 00:04:13 -0000 1.1.1.1 --- heredocs.dat 30 Apr 2005 04:48:29 -0000 1.2 *************** *** 1,16 **** ! # -*- perl -*- ! Dubbler: action=register plugin=Chilts::PtfDeleteAllSections ! Dubbler: action=register plugin=Chilts::PtfAddSection ! ! PtfDeleteAllSections: confirm ! ! PtfAddSection: section=HER1 name=<<NAME layout=1 ! Section on One Line ! NAME ! PtfAddSection: section=HER2 name=<<NAME desc=<<DESC add_to_end ! 2nd HereNow << Test ! NAME ! But this one also has a long description, which also has newlines in it. ! Like just then. ! And here too. ! DESC --- 1,7 ---- ! HereDocs1: val=<<HEREDOC ! This is a 1 liner heredoc ! HEREDOC ! HereDocs2: val=<<HEREDOC ! This is a ! 2 liner heredoc ! HEREDOC Index: arrays.dat =================================================================== RCS file: /cvsroot/data-pluginfile/data-pluginfiles/t/arrays.dat,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** arrays.dat 30 Apr 2005 00:04:13 -0000 1.1.1.1 --- arrays.dat 30 Apr 2005 04:48:29 -0000 1.2 *************** *** 1,4 **** ! Dubbler: action=print action=edit action=cut action=paste other=action ! DubblerA: a=a0 a=a1 a=a2 a=a3 a=a4 a=a5 ! DubblerB: b=1 b=2 b=3 b=4 b=5 b=6 ! DubblerC: a=a1 b=b1 a=a2 b=b2 c=c1 d=d1 c=c2 d=d2 a=a3 b=b3 --- 1,2 ---- ! Arrays1: val=a val=b val=c ! Arrays2: par1=a par1=b par1=c par2=d par2=e |