@@ -83,6 +83,21 @@ is( \%Test::MockFile::files_being_mocked, {}, "No mock files are in cache" ) or
8383 ok( seek ( $fh , 0, 0 ), 0, " Seek to start of file returns true" );
8484 is( sysseek( $fh , 0, 0 ), " 0 but true" , " sysseek to start of file returns '0 but true' to make it so." );
8585 ok( sysseek( $fh , 0, 0 ), " sysseek to start of file returns true when checked with ok()" );
86+
87+ ok( sysseek( $fh , 5, 0 ), " sysseek to position 5 returns true." );
88+ ok( sysseek( $fh , 10, 1 ), " Seek 10 bytes forward from the current position." );
89+ is( sysseek( $fh , 0, 1 ), 15, " Current position is 15 bytes from start." );
90+
91+ $buf = " " ;
92+ is( sysread ( $fh , $buf , 2, 0 ), 2, " Read 2 bytes from current position (10)." );
93+ is( $buf , " PQ" , " Line is as expected." );
94+
95+ ok( sysseek( $fh , -5, 2 ), " Seek 5 bytes back from end of file." );
96+ is( sysseek( $fh , 0, 1 ), 46, " Current position is 46 bytes from start." );
97+
98+ $buf = " " ;
99+ is( sysread ( $fh , $buf , 3, 0 ), 3, " Read 3 bytes from current position (46)." );
100+ is( $buf , " vwx" , " Line is as expected." );
86101}
87102
88103{
@@ -122,6 +137,23 @@ is( \%Test::MockFile::files_being_mocked, {}, "No mock files are in cache" ) or
122137 is( sysseek( $fh , 0, 0 ), " 0 but true" , " sysseek to start of file returns '0 but true' to make it so." );
123138 ok( sysseek( $fh , 0, 0 ), " sysseek to start of file returns true when checked with ok()" );
124139
140+ ok( sysseek( $fh , 5, 0 ), " sysseek to position 5 returns true." );
141+ ok( sysseek( $fh , 10, 1 ), " Seek 10 bytes forward from the current position." );
142+ is( sysseek( $fh , 0, 1 ), 15, " Current position is 15 bytes from start." );
143+
144+ $buf = " " ;
145+ is( sysread ( $fh , $buf , 2, 0 ), 2, " Read 2 bytes from current position (10)." );
146+ is( $buf , " PQ" , " Line is as expected." );
147+
148+ ok( sysseek( $fh , -5, 2 ), " Seek 5 bytes back from end of file." );
149+ is( sysseek( $fh , 0, 1 ), 46, " Current position is 46 bytes from start." );
150+
151+ $buf = " " ;
152+ is( sysread ( $fh , $buf , 3, 0 ), 3, " Read 3 bytes from current position (46)." );
153+ is( $buf , " vwx" , " Line is as expected." );
154+
155+ like( dies { sysseek( $fh , 10, 3 ) }, qr / Invalid whence value/ , " Dies when given an invalid whence value." );
156+
125157 close $fh ;
126158 undef $bar ;
127159}
0 commit comments