diff options
author | David Landgren <david@landgren.net> | 2006-04-28 16:27:39 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-04-28 13:33:37 +0000 |
commit | 7e35a6a8bf1225db0ee95fcad4562a278d354f34 (patch) | |
tree | ff2420df00aebc8186f16f502a6a8c05c8f0e182 /t/op/defins.t | |
parent | 7583b5e813037170a00f403278e6eaa59eb0048d (diff) | |
download | perl-7e35a6a8bf1225db0ee95fcad4562a278d354f34.tar.gz |
t/op/defins.pl using test.pl
Message-ID: <44520A3B.1080707@landgren.net>
p4raw-id: //depot/perl@28000
Diffstat (limited to 't/op/defins.t')
-rwxr-xr-x | t/op/defins.t | 86 |
1 files changed, 38 insertions, 48 deletions
diff --git a/t/op/defins.t b/t/op/defins.t index 06d48b601b..9f1d12897d 100755 --- a/t/op/defins.t +++ b/t/op/defins.t @@ -6,118 +6,110 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = qw(. ../lib); $SIG{__WARN__} = sub { $warns++; warn $_[0] }; - print "1..14\n"; } +require 'test.pl'; +plan( tests => 19 ); $wanted_filename = $^O eq 'VMS' ? '0.' : '0'; $saved_filename = $^O eq 'MacOS' ? ':0' : './0'; - -print "not " if $warns; -print "ok 1\n"; + +cmp_ok($warns,'==',0,'no warns at start'); open(FILE,">$saved_filename"); +ok(defined(FILE),'created work file'); print FILE "1\n"; print FILE "0"; close(FILE); open(FILE,"<$saved_filename"); +ok(defined(FILE),'opened work file'); my $seen = 0; my $dummy; while (my $name = <FILE>) { $seen++ if $name eq '0'; - } -print "not " unless $seen; -print "ok 2\n"; + } +cmp_ok($seen,'==',1,'seen in while()'); seek(FILE,0,0); $seen = 0; my $line = ''; -do +do { $seen++ if $line eq '0'; } while ($line = <FILE>); - -print "not " unless $seen; -print "ok 3\n"; - +cmp_ok($seen,'==',1,'seen in do/while'); seek(FILE,0,0); -$seen = 0; -while (($seen ? $dummy : $name) = <FILE>) +$seen = 0; +while (($seen ? $dummy : $name) = <FILE> ) { $seen++ if $name eq '0'; } -print "not " unless $seen; -print "ok 4\n"; +cmp_ok($seen,'==',1,'seen in while() ternary'); seek(FILE,0,0); -$seen = 0; -my %where; +$seen = 0; +my %where; while ($where{$seen} = <FILE>) { $seen++ if $where{$seen} eq '0'; } -print "not " unless $seen; -print "ok 5\n"; +cmp_ok($seen,'==',1,'seen in hash while()'); close FILE; opendir(DIR,($^O eq 'MacOS' ? ':' : '.')); +ok(defined(DIR),'opened current directory'); $seen = 0; while (my $name = readdir(DIR)) { $seen++ if $name eq $wanted_filename; - } -print "not " unless $seen; -print "ok 6\n"; + } +cmp_ok($seen,'==',1,'saw work file once'); rewinddir(DIR); -$seen = 0; +$seen = 0; $dummy = ''; while (($seen ? $dummy : $name) = readdir(DIR)) { $seen++ if $name eq $wanted_filename; } -print "not " unless $seen; -print "ok 7\n"; +cmp_ok($seen,'>',0,'saw file in while() ternary'); rewinddir(DIR); -$seen = 0; +$seen = 0; while ($where{$seen} = readdir(DIR)) { $seen++ if $where{$seen} eq $wanted_filename; } -print "not " unless $seen; -print "ok 8\n"; +cmp_ok($seen,'==',1,'saw file in hash while()'); $seen = 0; while (my $name = glob('*')) { $seen++ if $name eq $wanted_filename; - } -print "not " unless $seen; -print "ok 9\n"; + } +cmp_ok($seen,'==',1,'saw file in glob while()'); -$seen = 0; +$seen = 0; $dummy = ''; while (($seen ? $dummy : $name) = glob('*')) { $seen++ if $name eq $wanted_filename; } -print "not " unless $seen; -print "ok 10\n"; +cmp_ok($seen,'>',0,'saw file in glob hash while() ternary'); -$seen = 0; +$seen = 0; while ($where{$seen} = glob('*')) { $seen++ if $where{$seen} eq $wanted_filename; } -print "not " unless $seen; -print "ok 11\n"; +cmp_ok($seen,'==',1,'seen in glob hash while()'); unlink($saved_filename); +ok(!(-f $saved_filename),'work file unlinked'); my %hash = (0 => 1, 1 => 2); @@ -125,24 +117,22 @@ $seen = 0; while (my $name = each %hash) { $seen++ if $name eq '0'; - } -print "not " unless $seen; -print "ok 12\n"; + } +cmp_ok($seen,'==',1,'seen in each'); -$seen = 0; +$seen = 0; $dummy = ''; while (($seen ? $dummy : $name) = each %hash) { $seen++ if $name eq '0'; } -print "not " unless $seen; -print "ok 13\n"; +cmp_ok($seen,'==',1,'seen in each ternary'); -$seen = 0; +$seen = 0; while ($where{$seen} = each %hash) { $seen++ if $where{$seen} eq '0'; } -print "not " unless $seen; -print "ok 14\n"; +cmp_ok($seen,'==',1,'seen in each hash'); +cmp_ok($warns,'==',0,'no warns at finish'); |