diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-04-13 09:05:42 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-04-13 09:05:42 +0000 |
commit | 38b6b061609a699d69347e274af70317fcab2eed (patch) | |
tree | e900007a311756ec8522e8238a2661d708e42755 /t | |
parent | ad0e1adc0fee9674a1d13f4da0aca626291192ed (diff) | |
parent | a1457ef109a93b95271d1f893ff694db78a86c73 (diff) | |
download | perl-38b6b061609a699d69347e274af70317fcab2eed.tar.gz |
Integrate mainline
p4raw-id: //depot/perlio@9695
Diffstat (limited to 't')
-rwxr-xr-x | t/comp/proto.t | 6 | ||||
-rw-r--r-- | t/lib/md5-file.t | 2 | ||||
-rw-r--r-- | t/lib/time-hires.t | 176 | ||||
-rwxr-xr-x | t/op/pat.t | 29 |
4 files changed, 210 insertions, 3 deletions
diff --git a/t/comp/proto.t b/t/comp/proto.t index 5fce52685a..d0e0acbc0b 100755 --- a/t/comp/proto.t +++ b/t/comp/proto.t @@ -16,7 +16,7 @@ BEGIN { use strict; -print "1..124\n"; +print "1..125\n"; my $i = 1; @@ -502,3 +502,7 @@ for my $p ( "", qw{ () ($) ($@) ($%) ($;$) (&) (&\@) (&@) (%) (\%) (\@) } ) { # Not $$;$;$ print "not " unless prototype "CORE::substr" eq '$$;$$'; print "ok ", $i++, "\n"; + +# recv takes a scalar reference for its second argument +print "not " unless prototype "CORE::recv" eq '*\\$$$'; +print "ok ", $i++, "\n"; diff --git a/t/lib/md5-file.t b/t/lib/md5-file.t index ca9cac7472..d0f0d034a1 100644 --- a/t/lib/md5-file.t +++ b/t/lib/md5-file.t @@ -21,7 +21,7 @@ EOT } else { # ASCII $EXPECT = <<EOT; 3d0146bf194e4fe68733d00fba02a49e ext/Digest/MD5/MD5.pm -61debd0ec12e131e1ba220e2f3ad2d26 ext/Digest/MD5/MD5.xs +f32f264090fdd2b85a4a9be8b1342752 ext/Digest/MD5/MD5.xs EOT } diff --git a/t/lib/time-hires.t b/t/lib/time-hires.t new file mode 100644 index 0000000000..50c20f09ca --- /dev/null +++ b/t/lib/time-hires.t @@ -0,0 +1,176 @@ +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +BEGIN { $| = 1; print "1..17\n"; } + +END {print "not ok 1\n" unless $loaded;} + +use Time::HiRes qw(tv_interval); + +$loaded = 1; + +print "ok 1\n"; + +use strict; + +my $have_gettimeofday = defined &Time::HiRes::gettimeofday; +my $have_usleep = defined &Time::HiRes::usleep; +my $have_ualarm = defined &Time::HiRes::ualarm; + +import Time::HiRes 'gettimeofday' if $have_gettimeofday; +import Time::HiRes 'usleep' if $have_usleep; +import Time::HiRes 'ualarm' if $have_ualarm; + +sub skip { + map { print "ok $_ (skipped)\n" } @_; +} + +sub ok { + my ($n, $result, @info) = @_; + if ($result) { + print "ok $n\n"; + } + else { + print "not ok $n\n"; + print "# @info\n" if @info; + } +} + +if (!$have_gettimeofday) { + skip 2..6; +} +else { + my @one = gettimeofday(); + ok 2, @one == 2, 'gettimeofday returned ', 0+@one, ' args'; + ok 3, $one[0] > 850_000_000, "@one too small"; + + sleep 1; + + my @two = gettimeofday(); + ok 4, ($two[0] > $one[0] || ($two[0] == $one[0] && $two[1] > $one[1])), + "@two is not greater than @one"; + + my $f = Time::HiRes::time; + ok 5, $f > 850_000_000, "$f too small"; + ok 6, $f - $two[0] < 2, "$f - @two >= 2"; +} + +if (!$have_usleep) { + skip 7..8; +} +else { + my $one = time; + usleep(10_000); + my $two = time; + usleep(10_000); + my $three = time; + ok 7, $one == $two || $two == $three, "slept too long, $one $two $three"; + + if (!$have_gettimeofday) { + skip 8; + } + else { + my $f = Time::HiRes::time; + usleep(500_000); + my $f2 = Time::HiRes::time; + my $d = $f2 - $f; + ok 8, $d > 0.4 && $d < 0.8, "slept $d secs $f to $f2"; + } +} + +# Two-arg tv_interval() is always available. +{ + my $f = tv_interval [5, 100_000], [10, 500_000]; + ok 9, $f == 5.4, $f; +} + +if (!$have_gettimeofday) { + skip 10; +} +else { + my $r = [gettimeofday()]; + my $f = tv_interval $r; + ok 10, $f < 2, $f; +} + +if (!$have_usleep) { + skip 11; +} +else { + my $r = [gettimeofday()]; + #jTime::HiRes::sleep 0.5; + Time::HiRes::sleep( 0.5 ); + my $f = tv_interval $r; + ok 11, $f > 0.4 && $f < 0.8, "slept $f secs"; +} + +if (!$have_ualarm) { + skip 12..13; +} +else { + my $tick = 0; + local $SIG{ALRM} = sub { $tick++ }; + + my $one = time; $tick = 0; ualarm(10_000); sleep until $tick; + my $two = time; $tick = 0; ualarm(10_000); sleep until $tick; + my $three = time; + ok 12, $one == $two || $two == $three, "slept too long, $one $two $three"; + + $tick = 0; + ualarm(10_000, 10_000); + sleep until $tick >= 3; + ok 13, 1; + ualarm(0); +} + +# new test: did we even get close? + +{ + my $t = time(); + my $tf = Time::HiRes::time(); + ok 14, ($tf >= $t) && (($tf - $t) <= 1), + "time $t differs from Time::HiRes::time $tf"; +} + +unless (defined &Time::HiRes::gettimeofday + && defined &Time::HiRes::ualarm + && defined &Time::HiRes::usleep) { + for (15..17) { + print "ok $_ # skipped\n"; + } +} else { + use Time::HiRes qw (time alarm sleep); + + my ($f, $r, $i); + + print "# time..."; + $f = time; + print "$f\nok 15\n"; + + print "# sleep..."; + $r = [Time::HiRes::gettimeofday]; + sleep (0.5); + print Time::HiRes::tv_interval($r), "\nok 16\n"; + + $r = [Time::HiRes::gettimeofday]; + $i = 5; + $SIG{ALRM} = "tick"; + while ($i) + { + alarm(2.5); + select (undef, undef, undef, 10); + print "# Select returned! ", Time::HiRes::tv_interval ($r), "\n"; + } + + sub tick + { + print "# Tick! ", Time::HiRes::tv_interval ($r), "\n"; + $i--; + } + $SIG{ALRM} = 'DEFAULT'; + + print "ok 17\n"; +} + diff --git a/t/op/pat.t b/t/op/pat.t index c3024a2f2d..1d2e632e6a 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -5,7 +5,7 @@ # that does fit that format, add it to op/re_tests, not here. $| = 1; -print "1..581\n"; +print "1..586\n"; BEGIN { chdir 't' if -d 't'; @@ -1547,3 +1547,30 @@ print "ok 247\n"; print "ok 581\n"; } + +{ + $test = 582; + + # bugid 20010410.006 + for my $rx ( + '/(.*?)\{(.*?)\}/csg', + '/(.*?)\{(.*?)\}/cg', + '/(.*?)\{(.*?)\}/sg', + '/(.*?)\{(.*?)\}/g', + '/(.+?)\{(.+?)\}/csg', + ) + { + my($input, $i); + + $i = 0; + $input = "a{b}c{d}"; + eval <<EOT; + while (eval \$input =~ $rx) { + print "# \\\$1 = '\$1' \\\$2 = '\$2'\n"; + ++\$i; + } +EOT + print "not " unless $i == 2; + print "ok " . $test++ . "\n"; + } +} |