Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Parrot::Test and TODO

1 view
Skip to first unread message

Dan Sugalski

unread,
Apr 28, 2004, 11:59:45 AM4/28/04
to perl6-i...@perl.org
Apparently it doesn't work. A good task for the perl hackers with some time.

Go for it, good luck, patches welcome. :)
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Chromatic

unread,
Apr 28, 2004, 12:21:34 PM4/28/04
to Dan Sugalski, perl6-i...@perl.org
On Wed, 2004-04-28 at 08:59, Dan Sugalski wrote:

> Apparently it doesn't work.

Hm, I think it does work, just not the way Leo wants. I'll look again
today.

-- c

Dan Sugalski

unread,
Apr 28, 2004, 12:33:47 PM4/28/04
to chromatic, perl6-i...@perl.org

Cool. If they do work, could you fire a quick note on how to the
list, so I don't forget again?

Chromatic

unread,
Apr 28, 2004, 12:48:32 PM4/28/04
to Dan Sugalski, perl6-i...@perl.org
On Wed, 2004-04-28 at 09:33, Dan Sugalski wrote:

> Cool. If they do work, could you fire a quick note on how to the
> list, so I don't forget again?

Alright, here's a TODO test:

use Parrot::Test tests => 2;
use Test::More;

TODO:
{
local $TODO = 'Not implemented yet';
ok( 0, 'Sufficiently large values of zero are true' );
is( 1, 2, 'Sufficiently large values of one are two' );
}

Since Parrot::Test doesn't export TODO or $TODO, you have to use
Test::More. Once you've done that, create a new block labelled TODO to
contain all of the tests that may fail. Localize the global $TODO with
the reason you want to display and write your tests as normal.

If you run this file directly, you'll see the failures with the $TODO
reason in the test comment:

$ perl -Ilib t/todo_example.t

not ok 1 - Sufficiently large values of zero are true # TODO Not
implemented yet
# Failed (TODO) test (t/example.t at line 9)
not ok 2 - Sufficiently large values of one are two # TODO Not
implemented yet
# Failed (TODO) test (t/example.t at line 10)
# got: '1'
# expected: '2'

If you run this through Test::Harness, it'll pick up on the # TODO
comments and report that the tests succeeded. (Hey, they failed, but
you expected them to fail, so everything is okay.)

$ perl t/harness t/todo_example.t
t/example....ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.08 cusr + 0.00 csys = 0.08
CPU)

If for some reason one of the tests suddenly starts to succeed, you'll
see a different message from the harness:

$ perl t/harness t/example.t
t/example....ok
1/2 unexpectedly succeeded
All tests successful (1 subtest UNEXPECTEDLY SUCCEEDED).
Files=1, Tests=2, 0 wallclock secs ( 0.07 cusr + 0.01 csys = 0.08
CPU)

Leo wants the harness to report TODO tests that fail as expected; that's
a little more complex, but it's doable.

-- c

Dan Sugalski

unread,
Apr 28, 2004, 12:50:57 PM4/28/04
to chromatic, perl6-i...@perl.org
At 9:48 AM -0700 4/28/04, chromatic wrote:
>If for some reason one of the tests suddenly starts to succeed, you'll
>see a different message from the harness:
>
>$ perl t/harness t/example.t
>t/example....ok
> 1/2 unexpectedly succeeded
>All tests successful (1 subtest UNEXPECTEDLY SUCCEEDED).
>Files=1, Tests=2, 0 wallclock secs ( 0.07 cusr + 0.01 csys = 0.08
>CPU)

Cool--thanks much for the explanation.

>Leo wants the harness to report TODO tests that fail as expected; that's
>a little more complex, but it's doable.

If you can, great. If not, even this is fine.

Leopold Toetsch

unread,
Apr 28, 2004, 2:31:59 PM4/28/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

>>Leo wants the harness to report TODO tests that fail as expected; that's
>>a little more complex, but it's doable.

> If you can, great. If not, even this is fine.

Well, there is exactly one TODO test in t/pmc/*. It you have a look at
that one "this is fine" :)

leo

0 new messages