Skip to content

Commit ae5b750

Browse files
committed
Add tests for unchomped lines
1 parent a804241 commit ae5b750

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

S17-supply/lines.t

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use Test;
55
use Test::Tap;
66

77
my @simple = <a b c d e>;
8+
my @original;
89
my @endings = "\n", "\r", "\r\n";
910

10-
plan 11;
11+
plan 21;
1112

1213
dies_ok { Supply.lines }, 'can not be called as a class method';
1314

@@ -16,19 +17,31 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
1617

1718
tap_ok Supply.for( @simple.map: * ~ "\n" ).lines,
1819
@simple,
19-
"we can handle a simple list of lines with LF";
20+
"handle a simple list of lines with LF";
21+
tap_ok Supply.for( @original = @simple.map: * ~ "\n" ).lines(:!chomp),
22+
@original,
23+
"handle a simple list of lines with LF without chomping";
2024

2125
tap_ok Supply.for( @simple.map: * ~ "\r" ).lines,
2226
@simple,
23-
"we can handle a simple list of lines with CR";
27+
"handle a simple list of lines with CR";
28+
tap_ok Supply.for( @original = @simple.map: * ~ "\r" ).lines(:!chomp),
29+
@original,
30+
"handle a simple list of lines with CR without chomping";
2431

2532
tap_ok Supply.for( @simple.map: * ~ "\r\n" ).lines,
2633
@simple,
27-
"we can handle a simple list of lines with CRLF";
34+
"handle a simple list of lines with CRLF";
35+
tap_ok Supply.for( @original = @simple.map: * ~ "\r\n" ).lines(:!chomp),
36+
@original,
37+
"handle a simple list of lines with CRLF without chomping";
2838

2939
tap_ok Supply.for( @simple.map: * ~ @endings.pick ).lines,
3040
@simple,
31-
"we can handle a simple list of lines with mixed line ending";
41+
"handle a simple list of lines with mixed line ending";
42+
tap_ok Supply.for(@original= @simple.map: * ~ @endings.pick).lines(:!chomp),
43+
@original,
44+
"handle a simple list of lines with mixed line ending w/o chomping";
3245

3346
{
3447
my $s = Supply.new;
@@ -43,4 +56,18 @@ for ThreadPoolScheduler.new, CurrentThreadScheduler -> $*SCHEDULER {
4356
$s.done;
4457
} );
4558
}
59+
60+
{
61+
my $s = Supply.new;
62+
tap_ok $s.lines(:!chomp),
63+
["a\n","b\r\n","c\r","d\n","\n","eeee"],
64+
"handle chunked lines",
65+
:after-tap( {
66+
$s.more( "a\nb\r" );
67+
$s.more( "\nc\rd\n" );
68+
$s.more( "\ne" );
69+
$s.more( "eee" );
70+
$s.done;
71+
} );
72+
}
4673
}

0 commit comments

Comments
 (0)