Debian lenny version packages
[pkg-perl] / deb-src / libio-stringy-perl / io-stringy-2.110 / t / IO_WrapTie.t
1 #!/usr/bin/perl -w         #-*-Perl-*-
2
3 use lib "./t";
4 use IO::Handle;
5 use IO::Scalar;
6 use ExtUtils::TBone;
7 use IO::WrapTie;
8
9 #--------------------
10 #
11 # TEST...
12 #
13 #--------------------
14
15 # Make a tester:
16 my $T = typical ExtUtils::TBone;
17
18 # Set the counter:
19 unless ($] >= 5.004) {
20     $T->begin(1);
21     $T->ok(1);
22     $T->end;
23     exit 0;
24 }
25 $T->begin(6);
26
27 my $hello = 'Hello, ';
28 my $world = "world!\n";
29
30 #### test
31 my $s = '';
32 my $SH = new IO::WrapTie 'IO::Scalar', \$s;
33 $T->ok(1, "Construction");
34
35 #### test
36 print $SH $hello, $world;
37 $T->ok($s eq "$hello$world",
38        "print FH ARGS",
39        S => $s);
40
41 #### test
42 $SH->print($hello, $world);
43 $T->ok($s eq "$hello$world$hello$world",
44        "FH->print(ARGS)",
45        S => $s);
46       
47 #### test
48 $SH->seek(0,0);
49 $T->ok(1, "FH->seek(0,0)");
50
51 #### test
52 @x = <$SH>;
53 $T->ok((($x[0] eq "$hello$world") &&
54         ($x[1] eq "$hello$world") &&
55         !$x[2]),
56        "array = <FH>");
57
58 #### test
59 my $sref = $SH->sref;
60 $T->ok($sref eq \$s, "FH->sref");
61
62
63 # So we know everything went well...
64 $T->end;
65
66