File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# Test nqp::op line reading operations.
4
4
5
- plan (12 );
5
+ plan (18 );
6
6
7
7
my $ test-file := ' line-seps-test-file' ;
8
8
@@ -49,3 +49,25 @@ my $test-file := 'line-seps-test-file';
49
49
50
50
nqp :: unlink ($ test-file );
51
51
}
52
+
53
+ {
54
+ my $ wfh := nqp :: open ($ test-file , ' w' );
55
+ nqp ::printfh($ wfh , " abc\n def\r\n ghi" );
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
+ }
You can’t perform that action at this time.
0 commit comments