On Fri, Jul 18, 2003 at 06:36:41PM +0100, Tony Bowden wrote: > What's the current approach to turning perlbugs into tests? > > Should they be done as TODOs? Is there a distinct set of test files for > them? etc? Can they use Test::More? etc. etc. etc. > > e.g. http://bugs6.perl.org/rt2/Ticket/Display.html?id=5430 > > can have a fairly simple test like: > > package main; > eval '::is(__PACKAGE__, "main", "Package is main inside eval")'; > package Foo; > eval '::is(__PACKAGE__, "Foo", "Package is Foo inside eval")'; > > But how we actually get that into the core somewhere?
Just stick it into the core as a normal TODO test. This way we at least know when it gets fixed and can close the bug. In this case, t/op/eval.t. Either Test::More can be used or t/test.pl, a similar interface that uses less Perl core features. In the case of eval.t, use t/test.pl since its a pretty basic op. There's some more docs about this in perlhack. Often, a test will not be written using Test::More or test.pl. In that case you can introduce new tests at the bottom and update the counter manually using curr_test() so the old and new styles live together rather than having to rewrite the whole test. --- t/op/eval.t 2003/07/19 04:13:11 1.1 +++ t/op/eval.t 2003/07/19 04:23:33 @@ -5,7 +5,8 @@ @INC = '../lib'; } -print "1..91\n"; +require './test.pl'; +print "1..93\n"; eval 'print "ok 1\n";'; @@ -381,7 +382,7 @@ print DB::db5() == 3 ? 'ok' : 'not ok', " $test\n"; $test++; print db6() == 4 ? 'ok' : 'not ok', " $test\n"; $test++; } -require './test.pl'; + $NO_ENDING = 1; # [perl #19022] used to end up with shared hash warnings # The program should generate no output, so anything we see is on stderr @@ -437,4 +438,15 @@ print "$r$c" eq 'SS' ? "ok " : "# '$r$c' ne 'SS'\nnot ok ", $test++, "\n"; eval $code; print $c eq 'V' ? "ok " : "# '$c' ne 'V'\nnot ok ", $test++, "\n"; +} + + +{ + curr_test($test); + package main; + eval q{::is(__PACKAGE__, 'main', 'Package is main inside eval')}; + + local $TODO = 'Bug #5430'; + package Foo; + eval q{::is(__PACKAGE__, 'Foo', 'Package is Foo inside eval')}; } TODO tests work fine in the core, but a normal 'make test' doesn't currently report them. 'make test_harness' will, but they're still a little hard to track down because the harnesses don't have much support for that part at the moment. -- "A Masterpiece." "Well, better than average, maybe."