Re: ANNOUNCE: Pod::Coverage 0.06 (with discourse Re: ANNOUNCE: Pod::Coverage 0.02 release)
On Sun, Sep 02, 2001 at 01:57:01AM +0100, Richard Clamp wrote: > Tony, can you give me feedback on if 0.06 is now more like what you > hacked 0.02 into, or does it still need that separate _load_code > interface? I think it does. Perhaps, I haven't quite delved deeply enough, but the issue I faced previous is that Devel::Symdump requires a package name in the Foo::Bar syntax, but doing a require() on that will fail if the package isn't actually installed yet. The other way to look at this is that loading the code is a very distinct activity from parsing it, so should be in a distinct method. Never make methods do too much, especially when you're expecting people to subclass. Tony -- -- Tony Bowden | [EMAIL PROTECTED] | http://www.tmtm.com/ the woods are lovely, dark, and deep, but I have promises to keep --
Re: [PATCH t/op/srand.t t/op/rand.t pod/perlfunc.pod MANIFEST]Tests for srand()
01-09-03 13.43, skrev Michael G Schwern på [EMAIL PROTECTED] följande: > I've split off the srand() tests into their own test file and added in > some more. > > I've discovered a bug/undocumented feature. srand() appears to take > integers, at least on Linux. Perl silently truncates them. It > appears that's because ANSI C's srand takes an unsigned integer. > I've added docs to perlfunc that reflect this. Applied as #11840 and #11841 (oops), thanks! -- Arthur
Re: [PATCH] CGI::Cookie, Apache & Switch tests
01-09-03 03.38, skrev Michael G Schwern på [EMAIL PROTECTED] följande: > Andrew Wilson wrote up tests for CGI::Switch, CGI::Apache and > CGI::Cookie. Applied as #11836, thanks! -- Arthur
Re: [PATCH t/op/time.t] Partial cleanup
01-09-03 12.29, skrev Michael G Schwern på [EMAIL PROTECTED] följande: > This adds an ok() function to t/op/time.t and names each test. > I also added a test for the scalar version of localtime. > > It also turns this really interesting way to say "grep" > > index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0) > > into a grep. > > Once I sync up Test::More I can do proper skip testing on this instead > of that exit-in-the-middle. > > > --- t/op/time.t 2001/09/03 10:04:44 1.1 > +++ t/op/time.t 2001/09/03 10:19:08 Applied as #11838, thanks! -- Arthur
Re: [PATCH t/op/srand.t t/op/rand.t pod/perlfunc.pod MANIFEST] Tests for srand()
On Mon, 3 Sep 2001 07:43:00 -0400, in perl.perl5.porters you wrote: > +# Check that srand() isn't effected by $_ *a*ffected. > + 'srand(), no arg, not effected by $_'); And again. --- t/op/srand.t.orig Mon Sep 3 13:07:28 2001 +++ t/op/srand.tMon Sep 3 20:27:36 2001 @@ -41,7 +41,7 @@ ok( !eq_array(\@first_run, \@second_run), 'srand(), no arg, different rands'); -# Check that srand() isn't effected by $_ +# Check that srand() isn't affected by $_ { local $_ = 42; srand(); @@ -51,7 +51,7 @@ @second_run = mk_rand; ok( !eq_array(\@first_run, \@second_run), - 'srand(), no arg, not effected by $_'); + 'srand(), no arg, not affected by $_'); } End of patch. Cheers, Philip
[PATCH t/op/time.t] Partial cleanup
This adds an ok() function to t/op/time.t and names each test. I also added a test for the scalar version of localtime. It also turns this really interesting way to say "grep" index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0) into a grep. Once I sync up Test::More I can do proper skip testing on this instead of that exit-in-the-middle. --- t/op/time.t 2001/09/03 10:04:44 1.1 +++ t/op/time.t 2001/09/03 10:19:08 @@ -2,8 +2,27 @@ # $RCSfile: time.t,v $$Revision: 1.1 $$Date: 2001/09/03 10:04:44 $ -if ($does_gmtime = gmtime(time)) { print "1..6\n" } -else { print "1..3\n" } +if ( $does_gmtime = gmtime(time) ) { +print "1..7\n" +} +else { +print "1..4\n" +} + + +my $test = 1; +sub ok ($$) { +my($ok, $name) = @_; + +# You have to do it this way or VMS will get confused. +print $ok ? "ok $test - $name\n" : "not ok $test - $name\n"; + +printf "# Failed test at line %d\n", (caller)[2] unless $ok; + +$test++; +return $ok; +} + ($beguser,$begsys) = times; @@ -11,7 +30,7 @@ while (($now = time) == $beg) { sleep 1 } -if ($now > $beg && $now - $beg < 10){print "ok 1\n";} else {print "not ok 1\n";} +ok($now > $beg && $now - $beg < 10, 'very basic time test'); for ($i = 0; $i < 10; $i++) { ($nowuser, $nowsys) = times; @@ -20,34 +39,37 @@ last if time - $beg > 20; } -if ($i >= 20) {print "ok 2\n";} else {print "not ok 2\n";} +ok($i >= 20,'very basic times test'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg); ($xsec,$foo) = localtime($now); $localyday = $yday; -if ($sec != $xsec && $mday && $year) -{print "ok 3\n";} -else -{print "not ok 3\n";} +ok($sec != $xsec && $mday && $year, 'localtime() list context'); + +ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ] +(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ] +([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$ + /x, + 'localtime(), scalar context' + ); exit 0 unless $does_gmtime; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg); ($xsec,$foo) = localtime($now); -if ($sec != $xsec && $mday && $year) -{print "ok 4\n";} -else -{print "not ok 4\n";} - -if (index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0) -{print "ok 5\n";} -else -{print "not ok 5\n";} +ok($sec != $xsec && $mday && $year, 'gmtime() list context'); + +my $day_diff = $localyday - $yday; +ok( grep({ $day_diff == $_ } (0, 1, -1, 364, 365, -364, -365)), + 'gmtime() and localtime() agree what day of year'); + # This could be stricter. -if (gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ \d]\d) (\d\d):(\d\d):(\d\d) (\d\d\d\d)$/) -{print "ok 6\n";} -else -{print "not ok 6\n";} +ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ] + (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ] + ([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$ + /x, + 'gmtime(), scalar context' + ); -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One ScHWeRnsChweRNsChWErN SchweRN SCHWErNSChwERnsCHwERN sChWErn ScHWeRn schweRn sCHWErN schWeRnscHWeRN SchWeRN scHWErn SchwErn scHWErn ScHweRN sChwern scHWerNscHWeRn scHWerNScHwerN SChWeRN scHWeRn SchwERNschwERnSCHwern sCHWErN SCHWErN sChWeRn
Re: [PATCH t/op/rand.t] Increase the repetitions
01-09-03 12.24, skrev Michael G Schwern på [EMAIL PROTECTED] följande: > The folks on [EMAIL PROTECTED] were musing that the rand() tests are > documented to fail about 1% of the time. Now that we're smoke > testing, we're easily running it a few dozen times a day and that 1% > is going to start showing up. Applied as #11837, thanks! -- Arthur
Re: What in t/op can use Test::More and what can't.
On Mon, Sep 03, 2001 at 05:30:21PM +0100, Nicholas Clark wrote: > > t/op/numconvert.t Yes (I don't understand the warning at the top) > > Which warning would that be? Would you believe "# Repent for the end is near?" I have no idea what I was talking about. > I think it's more likely to be "no, no gain" unless you feel that > > if ($nok) { > print "not ok $test\n"; > } else { > print "ok $test\n"; > } > > would gain from being replaced by a call to an ok function. numconvert.t has much, much more frightening concerns than just adding an ok() function. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One Milk is timeless.
[PATCH t/op/rand.t] Increase the repetitions
The folks on [EMAIL PROTECTED] were musing that the rand() tests are documented to fail about 1% of the time. Now that we're smoke testing, we're easily running it a few dozen times a day and that 1% is going to start showing up. So we simply push off the problem a bit by increasing the # of reps by an order of magnitude. This increases the time to run the test by about a half second on my machine (G3/266) so no biggie. Some statistics nut should recalculate the hints in the test based on this change. I also stripped the now pointless srand call. rand() should work fine without it. --- t/op/rand.t 2001/09/03 10:03:33 1.1 +++ t/op/rand.t 2001/09/03 10:03:59 @@ -25,11 +25,7 @@ print "1..11\n"; -srand; # Shouldn't need this with 5.004... - # But I'll include it now and test for - # whether we needed it later. - -my $reps = 1000; # How many times to try rand each time. +my $reps = 1; # How many times to try rand each time. # May be changed, but should be over 500. # The more the better! (But slower.) -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One "Let's face it," said bearded Rusty Simmons, opening a can after the race. "This is a good excuse to drink some beer." At 10:30 in the morning? "Well, it's past noon in Dublin," said teammate Mike [Joseph] Schwern. "It's our duty." -- "Sure, and It's a Great Day for Irish Runners" Newsday, Sunday, March 20, 1988
[PATCH t/op/srand.t t/op/rand.t pod/perlfunc.pod MANIFEST] Tests for srand()
I've split off the srand() tests into their own test file and added in some more. I've discovered a bug/undocumented feature. srand() appears to take integers, at least on Linux. Perl silently truncates them. It appears that's because ANSI C's srand takes an unsigned integer. I've added docs to perlfunc that reflect this. --- MANIFEST2001/09/03 10:44:48 1.2 +++ MANIFEST2001/09/03 10:44:59 @@ -2083,6 +2083,7 @@ t/op/splice.t See if splice works t/op/split.t See if split works t/op/sprintf.t See if sprintf works +t/op/srand.tSee if srand works t/op/stat.tSee if stat works t/op/study.t See if study works t/op/subst.t See if substitution works --- pod/perlfunc.pod2001/09/03 11:31:30 1.1 +++ pod/perlfunc.pod2001/09/03 11:37:23 @@ -4786,6 +4786,11 @@ so many old programs supply their own seed value (often C or C), but that isn't necessary any more. +Most implementations of C take an integer and will silently +truncate decimal numbers. This means C will usually +produce the same results as C. To be safe, always pass +C an integer. + In fact, it's usually not necessary to call C at all, because if it is not called explicitly, it is called implicitly at the first use of the C operator. However, this was not the case in version of Perl --- /dev/null Mon Sep 3 07:41:34 2001 +++ /usr/local/src/perl-current/t/op/srand.tMon Sep 3 07:41:34 2001 @@ -0,0 +1,63 @@ +#!./perl -w + +# Test srand. + +use strict; +use Test::More tests => 5; + +# Generate a load of random numbers. +# int() avoids possible floating point error. +sub mk_rand { map int rand 1, 1..100; } + + +# Check that rand() is deterministic. +srand(1138); +my @first_run = mk_rand; + +srand(1138); +my @second_run = mk_rand; + +ok( eq_array(\@first_run, \@second_run), 'srand(), same arg, same rands' ); + + +# Check that different seeds provide different random numbers +srand(31337); +@first_run = mk_rand; + +srand(1138); +@second_run = mk_rand; + +ok( !eq_array(\@first_run, \@second_run), + 'srand(), different arg, different rands' ); + + +# Check that srand() with no args provides different seeds. +srand(); +@first_run = mk_rand; + +srand(); +@second_run = mk_rand; + +ok( !eq_array(\@first_run, \@second_run), 'srand(), no arg, different rands'); + + +# Check that srand() isn't effected by $_ +{ +local $_ = 42; +srand(); +@first_run = mk_rand; + +srand(); +@second_run = mk_rand; + +ok( !eq_array(\@first_run, \@second_run), + 'srand(), no arg, not effected by $_'); +} + + + +# This test checks whether Perl called srand for you. +@first_run = `$^X -le "print int rand 100 for 1..100"`; +@second_run = `$^X -le "print int rand 100 for 1..100"`; + +ok( !eq_array(\@first_run, \@second_run), 'srand() called automatically'); --- t/op/rand.t 2001/09/03 11:07:09 1.2 +++ t/op/rand.t 2001/09/03 11:40:38 @@ -22,8 +22,8 @@ use strict; use Config; +use Test::More tests => 8; -print "1..11\n"; my $reps = 1; # How many times to try rand each time. # May be changed, but should be over 500. @@ -70,8 +70,6 @@ } -# Hints for TEST 1 -# # This test checks for one of Perl's most frequent # mis-configurations. Your system's documentation # for rand(2) should tell you what value you need @@ -81,13 +79,16 @@ # reason that the diagnostic message might get the # wrong value is that Config.pm is incorrect.) # -if ($max <= 0 or $max >= (2 ** $randbits)) {# Just in case... - print "# max=[$max] min=[$min]\nnot ok 1\n"; - print "# This perl was compiled with randbits=$randbits\n"; - print "# which is _way_ off. Or maybe your system rand is broken,\n"; - print "# or your C compiler can't multiply, or maybe Martians\n"; - print "# have taken over your computer. For starters, see about\n"; - print "# trying a better value for randbits, probably smaller.\n"; +unless (ok( !$max <= 0 or $max >= (2 ** $randbits))) {# Just in case... + print < 0); # Next more positive int -if ($off) { +unless (is( $off, 0 )) { $shouldbe = $Config{randbits} + $off; - print "# max=[$max] min=[$min]\nnot ok 1\n"; + print "# max=[$max] min=[$min]\n"; print "# This perl was compiled with randbits=$randbits on $^O.\n"; print "# Consider using randbits=$shouldbe instead.\n"; # And skip the remaining tests; they would be pointless now. print "# Skipping remaining tests until randbits is fixed.\n"; exit; -} else { - print "ok 1\n"; } -# Hints for TEST 2 -# + # This should always be true: 0 <= rand(1) < 1 # If this test is failing, something is seriously wrong, # either in perl or your system's rand function.
Re: [PATCH t/op/srand.t t/op/rand.t pod/perlfunc.pod MANIFEST]Tests for srand()
01-09-03 13.43, skrev Michael G Schwern på [EMAIL PROTECTED] följande: > I've split off the srand() tests into their own test file and added in > some more. > > I've discovered a bug/undocumented feature. srand() appears to take > integers, at least on Linux. Perl silently truncates them. It > appears that's because ANSI C's srand takes an unsigned integer. > I've added docs to perlfunc that reflect this. It truncates integers to ? integers? Maybe we should add a warning :) "Just because you use a decimal, your srand won't be more random!" -- Arthur
Re: [PATCH t/op/srand.t t/op/rand.t pod/perlfunc.pod MANIFEST] Tests for srand()
On Mon, Sep 03, 2001 at 01:47:24PM +0200, Arthur Bergman wrote: > > I've discovered a bug/undocumented feature. srand() appears to take > > integers, at least on Linux. Perl silently truncates them. It > > appears that's because ANSI C's srand takes an unsigned integer. > > I've added docs to perlfunc that reflect this. > > It truncates integers to ? integers? Errr, you know what I mean. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl6 Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One Jesus hates me. http://www.unamerican.com/