From cd346b2859236d69de687d1baa46c23e19af2202 Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Fri, 14 Dec 2012 22:00:22 -0500 Subject: [PATCH] Add regression tests for split on string of single wordspace or hex20. For: RT #116086 --- t/op/split.t | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/t/op/split.t b/t/op/split.t index 76836d9..47bd8e6 100644 --- a/t/op/split.t +++ b/t/op/split.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 103; +plan tests => 115; $FS = ':'; @@ -421,4 +421,55 @@ is($cnt, scalar(@ary)); # [perl #94490] constant folding should not invoke special split " " # behaviour. @_=split(0||" ","foo bar"); -is @_, 3, 'split(0||" ") is not treated like split(" ")'; +is @_, 3, 'split(0||" ") is not treated like split(" ")'; #' + +{ + my @results; + my $expr; + $expr = ' a b c '; + + @results = split /\s/, $expr; + is @results, 4, + "split on regex of single space metacharacter: captured 4 elements"; + is $results[0], '', + "split on regex of single space metacharacter: first element is empty string"; + + @results = split / /, $expr; + is @results, 4, + "split on regex of single whitespace: captured 4 elements"; + is $results[0], '', + "split on regex of single whitespace: first element is empty string"; + + @results = split " ", $expr; + is @results, 3, + "split on string of single whitespace: captured 3 elements"; + is $results[0], 'a', + "split on string of single whitespace: first element is non-empty"; + + $expr = " a \tb c "; + @results = split " ", $expr; + is @results, 3, + "split on string of single whitespace: captured 3 elements"; + is $results[0], 'a', + "split on string of single whitespace: first element is non-empty; multiple contiguous space characters"; +} + +TODO: { + local $::TODO = 'RT #116086: split "\x20" does not work as documented'; + my @results; + my $expr; + $expr = ' a b c '; + @results = split "\x20", $expr; + is @results, 3, + "RT #116086: split on string of single hex-20: captured 3 elements"; + is $results[0], 'a', + "RT #116086: split on string of single hex-20: first element is non-empty"; + + $expr = " a \tb c "; + @results = split "\x20", $expr; + is @results, 3, + "RT #116086: split on string of single hex-20: captured 3 elements"; + is $results[0], 'a', + "RT #116086: split on string of single hex-20: first element is non-empty; multiple contiguous space characters"; +} + -- 2.7.4