Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO::Handle::tell return 0, no matter what #3687

Closed
p6rt opened this issue Feb 15, 2015 · 7 comments
Closed

IO::Handle::tell return 0, no matter what #3687

p6rt opened this issue Feb 15, 2015 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Feb 15, 2015

Migrated from rt.perl.org#123838 (status was 'resolved')

Searchable as RT123838$

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

From @gfldex

$f = open("x", :w); $f.print("abc"); say $f.tell

returns 0, expected 3

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

From @pmqs

On Sun Feb 15 06​:46​:01 2015, gfldex wrote​:

$f = open("x", :w); $f.print("abc"); say $f.tell

returns 0, expected 3

tell seems to return the correct value when "seek" is called and when reading from a file. Issue only seems to be when writing.

Attached is a simple test harness for "tell".

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

From @pmqs

use v6;
use Test;

plan 10;

# L<S32​::IO/Functions/tell>

{
  my $f ;
  dies_ok { $f.tell }, "tell() on non IO​::Handle object handle fails";
}

my $test-path = "tempfile-tell-test";
my $test-contents = "ABCDEFG\n";

{
  # Write

  my $fh = open($test-path, :w);

  is $fh.tell, 0, "tell after opening file is 0";
  ok $fh.print($test-contents), "print ok";
  is $fh.tell, $test-contents.chars, "tell after print is { $test-contents.chars }";

  ok $fh.seek(2, 0), "seek to offset 2";
  is $fh.tell, 2, "tell after seek is 2";

  ok $fh.close(), "closed ok";

  dies_ok { $fh.tell }, "tell() on closed file fails";

}

{
  # Append

  my $fh = open($test-path, :a);
  is $fh.tell, $test-contents.chars, "tell after opening for append is { $test-contents.chars }";

  ok $fh.close(), "closed ok";
}

{
  # Read

  my $fh = open($test-path, :r);

  is $fh.tell, 0, "tell after opening file for reading is 0";
  $fh.read(3), "print ok";
  is $fh.tell, 3, "tell after read is 3";

  ok $fh.close(), "closed ok";

  dies_ok { $fh.tell }, "tell() on closed file fails";

}

unlink $test-path;
CATCH {
  unlink $test-path;
}

# vim​: ft=perl6

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 26, 2016

From @zoffixznet

Seems to be fixed in latest Rakudo, per http://irclog.perlgeek.de/perl6/2016-09-26#i_13283196

Tests needed.

@p6rt
Copy link
Author

p6rt commented Apr 24, 2017

From @zoffixznet

On Mon, 26 Sep 2016 05​:37​:11 -0700, cpan@​zoffix.com wrote​:

Seems to be fixed in latest Rakudo, per
http://irclog.perlgeek.de/perl6/2016-09-26#i_13283196

Tests needed.

Tests added in Raku/roast@ea137f64d3

- IO grant

@p6rt
Copy link
Author

p6rt commented Apr 24, 2017

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Apr 24, 2017
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant