diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-11-04 19:48:32 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-11-04 19:48:32 +0000 |
commit | 0e7718d1e334a834bb11f7976318d1993cc7feb9 (patch) | |
tree | f34db41bf1527ffe6d2a705ed7b98e675dd9d166 /lib/Term | |
parent | 3eed716c43f574e5bb463b7e5770573ac4383150 (diff) | |
download | perl-0e7718d1e334a834bb11f7976318d1993cc7feb9.tar.gz |
Update Term::UI to 0.18
p4raw-id: //depot/perl@32220
Diffstat (limited to 'lib/Term')
-rw-r--r-- | lib/Term/UI.pm | 8 | ||||
-rw-r--r-- | lib/Term/UI/t/02_ui.t | 20 |
2 files changed, 23 insertions, 5 deletions
diff --git a/lib/Term/UI.pm b/lib/Term/UI.pm index c7cd4cd5b1..4b20faad9c 100644 --- a/lib/Term/UI.pm +++ b/lib/Term/UI.pm @@ -11,7 +11,7 @@ use strict; BEGIN { use vars qw[$VERSION $AUTOREPLY $VERBOSE $INVALID]; $VERBOSE = 1; - $VERSION = '0.16'; + $VERSION = '0.18'; $INVALID = loc('Invalid selection, please try again: '); } @@ -404,9 +404,9 @@ sub parse_options { my $return = {}; ### there's probably a more elegant way to do this... ### - while ( $input =~ s/(?:\s+)--?([-\w]+=("|').+?\2)(?=\Z|\s+)// or - $input =~ s/(?:\s+)--?([-\w]+=\S+)(?=\Z|\s+)// or - $input =~ s/(?:\s+)--?([-\w]+)(?=\Z|\s+)// + while ( $input =~ s/(?:^|\s+)--?([-\w]+=("|').+?\2)(?=\Z|\s+)// or + $input =~ s/(?:^|\s+)--?([-\w]+=\S+)(?=\Z|\s+)// or + $input =~ s/(?:^|\s+)--?([-\w]+)(?=\Z|\s+)// ) { my $match = $1; diff --git a/lib/Term/UI/t/02_ui.t b/lib/Term/UI/t/02_ui.t index 874ffc8d5b..6e0b34ae32 100644 --- a/lib/Term/UI/t/02_ui.t +++ b/lib/Term/UI/t/02_ui.t @@ -2,7 +2,7 @@ use strict; use lib qw[../lib lib]; -use Test::More tests => 13; +use Test::More tests => 19; use Term::ReadLine; use_ok( 'Term::UI' ); @@ -124,3 +124,21 @@ my $tmpl = { is_deeply($href, $expected, qq[Parsing options] ); is($rest, $munged, qq[Remaining unparsed string '$munged'] ); } + +### more parse_options tests +{ my @map = ( + [ 'x --update_source' => 'x', { update_source => 1 } ], + [ '--update_source' => '', { update_source => 1 } ], + ); + + for my $aref ( @map ) { + my( $input, $munged, $expect ) = @$aref; + + my($href,$rest) = $term->parse_options( $input ); + + ok( $href, "Parsed '$input'" ); + is_deeply( $href, $expect, + " Options parsed correctly" ); + is( $rest, $munged, " Command parsed correctly" ); + } +} |