File: prototype.t

package info (click to toggle)
libio-handle-util-perl 0.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 320 kB
  • sloc: perl: 1,353; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 599 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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

use ok 'IO::Handle::Prototype';

my $buf = '';

my $fh = IO::Handle::Prototype->new(
    print => sub {
        $buf .= $_[1];
    },
);

isa_ok( $fh, "IO::Handle::Prototype" );
isa_ok( $fh, "IO::Handle" );

can_ok( $fh, qw(getline read print write) );

eval { $fh->print("foo") };
is( $@, '', "no error" );
is( $buf, "foo", "callback worked" );

eval { $fh->getline };
like( $@, qr/getline/, "dies on missing callback" );

eval { $fh->write("foo") };
like( $@, qr/write/, "dies on missing callback" );

done_testing;

# ex: set sw=4 et: