Skip to content

Commit e220988

Browse files
committed
Test .seek failure modes; geekosaur++
Part of fix for #219
1 parent 3cc76b8 commit e220988

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

S32-io/seek.t

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ subtest 'SeekFromBeginning' => {
2121
$fh.seek: 20, SeekFromBeginning;
2222
is-deeply $fh.read(5).decode, 'ABCDE', 'two successive seeks';
2323

24-
# TODO XXX Currently throws just past beginning; Should it fail on both?
25-
# throws-like { $fh.seek: -300, SeekFromBeginning }, Exception,
26-
# 'seeking past beginning throws';
27-
#
28-
# throws-like { $fh.seek: 300, SeekFromBeginning }, Exception,
29-
# 'seeking past end throws';
24+
$fh.seek: 300, SeekFromBeginning;
25+
is $fh.tell, 300, 'seeking past end';
26+
27+
throws-like { $fh.seek: -300, SeekFromBeginning }, Exception,
28+
'seeking past beginning throws';
3029
}
3130

3231
subtest 'SeekFromCurrent' => {
@@ -51,14 +50,12 @@ subtest 'SeekFromCurrent' => {
5150
$fh.seek: -10, SeekFromCurrent;
5251
is-deeply $fh.read(5).decode, 'abcde', 'two successive seeks (neg, neg)';
5352

54-
# TODO XXX Currently throws just past beginning; Should it fail on both?
55-
# throws-like { $fh.seek: -300, SeekFromCurrent }, Exception,
56-
# 'seeking past beginning throws';
53+
$fh.seek: 0, SeekFromBeginning;
54+
$fh.seek: 300, SeekFromCurrent;
55+
is $fh.tell, 300, 'seeking past end';
5756

58-
# throws-like {
59-
# $fh.seek: 0, SeekFromBeginning;
60-
# $fh.seek: 300, SeekFromCurrent;
61-
# }, Exception, 'seeking past end throws';
57+
throws-like { $fh.seek: -3000, SeekFromCurrent }, Exception,
58+
'seeking past beginning throws';
6259
}
6360

6461
subtest 'SeekFromEnd' => {
@@ -73,12 +70,11 @@ subtest 'SeekFromEnd' => {
7370
$fh.seek: -10, SeekFromEnd;
7471
is-deeply $fh.read(5).decode, 'ABCDE', 'two successive seeks';
7572

76-
# TODO XXX Currently throws just past beginning; Should it fail on both?
77-
# throws-like { $fh.seek: -300, SeekFromEnd }, Exception,
78-
# 'seeking past beginning throws';
73+
$fh.seek: 300, SeekFromEnd;
74+
is $fh.tell, 330, 'seeking past end';
7975

80-
# throws-like { $fh.seek: 300, SeekFromEnd }, Exception,
81-
# 'seeking past end throws';
76+
throws-like { $fh.seek: -300, SeekFromEnd }, Exception,
77+
'seeking past beginning throws';
8278
}
8379

8480
# vim: ft=perl6

0 commit comments

Comments
 (0)