File: subclass.t

package info (click to toggle)
libstream-buffered-perl 0.2-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 176 kB
  • sloc: perl: 1,668; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

{
    package Stream::Buffered::Sub;
    use base 'Stream::Buffered';
}

{
    my $b = Stream::Buffered::Sub->new(-1);
    $b->print("foo");
    is $b->size, 3;
    my $fh = $b->rewind;
    is do { local $/; <$fh> }, 'foo';
    $fh->seek(0, 0);
}

{
    local $Stream::Buffered::MaxMemoryBufferSize = 12;
    my $b = Stream::Buffered::Sub->new;
    is $b->size, 0;
    $b->print("foo") for 1..5;
    is $b->size, 15;
    my $fh = $b->rewind;
    isa_ok $fh, 'IO::File';
    is do { local $/; <$fh> }, ('foo' x 5);
}

{
    local $Stream::Buffered::MaxMemoryBufferSize = 0;
    my $b = Stream::Buffered::Sub->new(3);
    $b->print("foo\n");
    is $b->size, 4;
    my $fh = $b->rewind;
    isa_ok $fh, 'IO::File';
    is do { local $/; <$fh> }, "foo\n";
}

done_testing;