summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E Keenan <jkeenan@cpan.org>2012-12-14 22:00:22 -0500
committerJames E Keenan <jkeenan@cpan.org>2012-12-15 14:35:27 -0500
commitcd346b2859236d69de687d1baa46c23e19af2202 (patch)
treef453d93bd1a6bc2a249465ccc1c83735e420a990
parent00dc1094c0ac51b243fa7ce402f90ec93eeeb2fa (diff)
downloadperl-cd346b2859236d69de687d1baa46c23e19af2202.tar.gz
Add regression tests for split on string of single wordspace or hex20.
For: RT #116086
-rw-r--r--t/op/split.t55
1 files changed, 53 insertions, 2 deletions
diff --git a/t/op/split.t b/t/op/split.t
index 76836d94c5..47bd8e66f7 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";
+}
+