This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
d826edec73c44fc3819698921cdaca795a04a8cc
[perl5.git] / cpan / File-Temp / t / cmp.t
1 #!perl -w
2 # Test overloading
3
4 use Test::More tests => 19;
5 use strict;
6
7 BEGIN {use_ok( "File::Temp" ); }
8
9 {
10   my $fh = new File::Temp();
11   isa_ok ($fh, 'File::Temp');
12
13   ok( "$fh" ne "foo", "compare stringified object with string");
14   ok( $fh ne "foo", "compare object with string");
15   ok( $fh eq $fh, "compare eq with self");
16
17   ok( $fh != 0, "compare != 0");
18   ok( $fh == $fh, "compare == with self");
19   ok( $fh != \*STDOUT, "compare != \*STDOUT");
20
21   {
22     my $num = $fh+0;
23     like ($num, qr/^\d+$/, '+0 is a number');
24   }
25   {
26     my $str = "$fh";
27     unlike ($str, qr/^\d+$/, '"" is not a number');
28   }
29 }
30
31 {
32   my $fh = File::Temp->newdir();
33   isa_ok ($fh, 'File::Temp::Dir');
34
35   ok( "$fh" ne "foo", "compare stringified object with string");
36   ok( $fh ne "foo", "compare object with string");
37   ok( $fh eq $fh, "compare eq with self");
38
39   ok( $fh != 0, "compare != 0");
40   ok( $fh == $fh, "compare == with self");
41   ok( $fh != \*STDOUT, "compare != \*STDOUT");
42
43   {
44     my $num = $fh+0;
45     like ($num, qr/^\d+$/, '+0 is a number');
46   }
47   {
48     my $str = "$fh";
49     unlike ($str, qr/^\d+$/, '"" is not a number');
50   }
51 }