File: binmode_bug.t

package info (click to toggle)
libfilehandle-unget-perl 0.1634-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: perl: 2,160; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 982 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use strict;
use FileHandle::Unget;
use File::Spec::Functions qw(:ALL);
use Test::More tests => 2;
use Config;
use File::Temp;

my $path_to_perl = $Config{perlpath};

TODO:
{
  if ($^O eq 'Win32')
  {
    if (require Win32)
    {
      local $TODO = 'This test is known to fail on your version of Windows'
        unless Win32::GetOSName() eq 'Win2000';
    }
    else
    {
      local $TODO = 'This test may fail on your version of Windows'
    }
  }

  my $tmp = File::Temp->new();

  {
    binmode $tmp;
    print $tmp "first line\n";
    print $tmp "second line\n";
    print $tmp "a line\n" x 1000;
    close $tmp;
  }

  # Test eof followed by binmode for streams (fails under Windows)
  {
    my $fh = new FileHandle::Unget("$path_to_perl -e \"open F, '" . $tmp->filename .
      "';binmode STDOUT;print <F>\" |");

    print '' if eof($fh);
    binmode $fh;

    # 1
    is(scalar <$fh>,"first line\n");

    # 2
    is(scalar <$fh>,"second line\n");

    $fh->close;
  }
}