Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (66 sloc) 2.81 KB
use v6;
use lib 't/spec/packages';
use Test;
use Test::Util;
plan 48;
for False, True -> $eager {
is "a\nb\n\nc".lines(:$eager).join('|'),
'a|b||c', 'LF .lines without trailing';
is "a\nb\n\nc\n".lines(:$eager).join('|'),
'a|b||c', 'LF .lines with trailing';
is "a\nb\n\nc\n".lines(Inf,:$eager).join('|'),
'a|b||c', 'LF .lines with Inf';
is "a\nb\n\nc\n".lines(*,:$eager).join('|'),
'a|b||c', 'LF .lines with *';
is "a\nb\n\nc\n".lines(2,:$eager).join('|'),
'a|b', 'LF .lines with limit';
is "a\rb\r\rc".lines(:$eager).join('|'),
'a|b||c', 'CR .lines without trailing';
is "a\rb\r\rc\r".lines(:$eager).join('|'),
'a|b||c', 'CR .lines with trailing';
is "a\rb\r\rc\r".lines(Inf,:$eager).join('|'),
'a|b||c', 'CR .lines with Inf';
is "a\rb\r\rc\r".lines(*,:$eager).join('|'),
'a|b||c', 'CR .lines with *';
is "a\rb\r\rc\r".lines(2,:$eager).join('|'),
'a|b', 'CR .lines with limit';
#?rakudo.jvm 5 todo '\r\n not yet handled as grapheme'
is "a\r\nb\r\n\r\nc".lines(:$eager).join('|'), 'a|b||c',
'CRLF .lines without trailing';
is "a\r\nb\r\n\r\nc\r\n".lines(:$eager).join('|'), 'a|b||c',
'CRLF .lines with trailing';
is "a\r\nb\r\n\r\nc\r\n".lines(Inf,:$eager).join('|'), 'a|b||c',
'CRLF .lines with Inf';
is "a\r\nb\r\n\r\nc\r\n".lines(*,:$eager).join('|'), 'a|b||c',
'CRLF .lines with *';
is "a\r\nb\r\n\r\nc\r\n".lines(2,:$eager).join('|'), 'a|b',
'CRLF .lines with limit';
is "a\nb\r\rc".lines(:$eager).join('|'),
'a|b||c', 'mixed .lines without trailing';
is "a\nb\r\rc\r".lines(:$eager).join('|'),
'a|b||c', 'mixed .lines with trailing';
is "a\nb\r\rc\r".lines(Inf,:$eager).join('|'),
'a|b||c', 'mixed .lines with Inf';
is "a\nb\r\rc\r".lines(*,:$eager).join('|'),
'a|b||c', 'mixed .lines with *';
is "a\nb\r\rc\r".lines(2,:$eager).join('|'),
'a|b', 'mixed .lines with limit';
is lines("a\nb\nc\n",:$eager).join('|'), 'a|b|c', '&lines';
is lines("a\nb\nc\n",2,:$eager).join('|'), 'a|b', '&lines(2)';
}
is lines("a\nb\nc\n",:count), 3, 'lines(Str, :count)';
is "a\nb\nc\n".lines(:count), 3, 'Str.lines(:count)';
# RT #115136
is_run( 'print lines[0]',
"abcd\nefgh\nijkl\n",
{ out => "abcd", err => '', status => 0 },
'lines returns things in lines' );
# RT #126270 [BUG] Something fishy with lines() and looping over two items at a time in Rakudo
{
my $expected = "A, then B\nC, then D\n";
my $result;
# This used to fail, saying "Too few positionals passed; expected 2 arguments but got 0"
for "A\nB\nC\nD".lines() -> $x, $y { $result ~= "$x, then $y\n" }
is $result, $expected, 'lines iterates correctly with for block taking two arguments at a time';
}
# vim: ft=perl6
Something went wrong with that request. Please try again.