xref: /openbsd-src/gnu/usr.bin/perl/cpan/File-Temp/t/cmp.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
1b39c5158Smillert#!perl -w
2b39c5158Smillert# Test overloading
3b39c5158Smillert
491f110e0Safresh1use Test::More tests => 19;
5b39c5158Smillertuse strict;
6b39c5158Smillert
7b39c5158SmillertBEGIN {use_ok( "File::Temp" ); }
8b39c5158Smillert
991f110e0Safresh1{
10*256a93a4Safresh1  my $fh = File::Temp->new();
1191f110e0Safresh1  isa_ok ($fh, 'File::Temp');
1291f110e0Safresh1
13b39c5158Smillert  ok( "$fh" ne "foo", "compare stringified object with string");
14b39c5158Smillert  ok( $fh ne "foo", "compare object with string");
1591f110e0Safresh1  ok( $fh eq $fh, "compare eq with self");
1691f110e0Safresh1
1791f110e0Safresh1  ok( $fh != 0, "compare != 0");
1891f110e0Safresh1  ok( $fh == $fh, "compare == with self");
1991f110e0Safresh1  ok( $fh != \*STDOUT, "compare != \*STDOUT");
2091f110e0Safresh1
2191f110e0Safresh1  {
2291f110e0Safresh1    my $num = $fh+0;
2391f110e0Safresh1    like ($num, qr/^\d+$/, '+0 is a number');
2491f110e0Safresh1  }
2591f110e0Safresh1  {
2691f110e0Safresh1    my $str = "$fh";
2791f110e0Safresh1    unlike ($str, qr/^\d+$/, '"" is not a number');
2891f110e0Safresh1  }
2991f110e0Safresh1}
3091f110e0Safresh1
3191f110e0Safresh1{
3291f110e0Safresh1  my $fh = File::Temp->newdir();
3391f110e0Safresh1  isa_ok ($fh, 'File::Temp::Dir');
3491f110e0Safresh1
3591f110e0Safresh1  ok( "$fh" ne "foo", "compare stringified object with string");
3691f110e0Safresh1  ok( $fh ne "foo", "compare object with string");
3791f110e0Safresh1  ok( $fh eq $fh, "compare eq with self");
3891f110e0Safresh1
3991f110e0Safresh1  ok( $fh != 0, "compare != 0");
4091f110e0Safresh1  ok( $fh == $fh, "compare == with self");
4191f110e0Safresh1  ok( $fh != \*STDOUT, "compare != \*STDOUT");
4291f110e0Safresh1
4391f110e0Safresh1  {
4491f110e0Safresh1    my $num = $fh+0;
4591f110e0Safresh1    like ($num, qr/^\d+$/, '+0 is a number');
4691f110e0Safresh1  }
4791f110e0Safresh1  {
4891f110e0Safresh1    my $str = "$fh";
4991f110e0Safresh1    unlike ($str, qr/^\d+$/, '"" is not a number');
5091f110e0Safresh1  }
5191f110e0Safresh1}
52