Skip to content

Commit c7104bc

Browse files
committed
Actually test the important \n/\r\n case.
1 parent a586598 commit c7104bc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

t/moar/03-line-seps.t

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Test nqp::op line reading operations.
44

5-
plan(12);
5+
plan(18);
66

77
my $test-file := 'line-seps-test-file';
88

@@ -49,3 +49,25 @@ my $test-file := 'line-seps-test-file';
4949

5050
nqp::unlink($test-file);
5151
}
52+
53+
{
54+
my $wfh := nqp::open($test-file, 'w');
55+
nqp::printfh($wfh, "abc\ndef\r\nghi");
56+
nqp::closefh($wfh);
57+
58+
my $rfh := nqp::open($test-file, 'r');
59+
nqp::setinputlineseps($rfh, nqp::list_s("\n", "\r\n"));
60+
ok(nqp::readlinefh($rfh) eq "abc\n", '\n separator used');
61+
ok(nqp::readlinefh($rfh) eq "def\r\n", '\r\n separator used');
62+
ok(nqp::readlinefh($rfh) eq "ghi", 'final read to end of file worked');
63+
nqp::closefh($rfh);
64+
65+
$rfh := nqp::open($test-file, 'r');
66+
nqp::setinputlineseps($rfh, nqp::list_s("\n", "\r\n"));
67+
ok(nqp::readlinechompfh($rfh) eq "abc", '\n separator used and chomped');
68+
ok(nqp::readlinechompfh($rfh) eq "def", '\r\n separator used and chomped');
69+
ok(nqp::readlinechompfh($rfh) eq "ghi", 'final read to end of file worked');
70+
nqp::closefh($rfh);
71+
72+
nqp::unlink($test-file);
73+
}

0 commit comments

Comments
 (0)