ok(1,1) vs. ok ('foo','foo') in Test::More

=2D----BEGIN PGP SIGNED MESSAGE-----

Moin,

is there a re reason that the following warns:

	% perl -MTest::More -le 'plan tests =3D> 1; ok (1,1)'
	1..1
	#     You named your test '1'.  You shouldn't use numbers for your test
	 names.
	#     Very confusing.

and this not:

	ok 1 - 1
	% perl -MTest::More -le 'plan tests =3D> 1; ok ('foo','foo')'
	1..1
	ok 1 - foo

This has prevented me from "converting" several huge old testsuites from=20
"use Test;" to "use Test::More;" because I know that I would then have to=20
go and add testnames to thousand of tests (e.g. all tests that test for=20
number output). This is very boring, and you can bet that I will come up=20
with "is ($foo->baz(), 12, 'is 12');" just to shut of the warnings. And bad=
=20
testnames are like bad comments, better have none than a bad or silly=20
one :)

If I could just change "Test;" to "Test::More;" without hundreds of warning=
s=20
springing on me I know I would convert the test scripts and then change=20
them step by step over to the new code (or not change them at all, because=
=20
don't change working code..)

Best wishes,

Tels

=2D --=20
 Signed on Tue Feb  3 18:38:48 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Nuclear powered vacuum cleaners will probably be ready within 10 years."
 Alex Lewyt, of the Lewyt Corporation, a vacuum maker, predicted in The New
 York Times on June 10, 1955 -- A warning to all technophiles

=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQB/d7HcLPEOTuEwVAQGOSQf/Ts+NZAAzLIZHXTInZKsqVH+FjOUrxxMS
DyTlQ7L6WyRqY3A7sqD/XwjjlqyZ7fbuL6qfNZV2V8QjmLgd+y5lVgy1UgtfAReb
JQx/6At/hpSJfxPrcQyaD1WXth5JPnMLeEypaNrtW3HXeLr09IQaQCFTLiJtO6pD
CzqhaXA7Sbblky7Rah38GYzmBEYdXNqnfST7ns5OVhU/WweGjxZFMsr+0cLnrAAm
uiIE1tlrJKwfGIIbZ6hE+6skD73DptptFi8ALhs9r0jpy19EKjfbiERW8ZYopVAp
gopvXWG9CPO4o6eFvBg2oLRC9VXcn0Hy1G6e+vkGdlz0YYNAO48f4w=3D=3D
=3DD2Lu
=2D----END PGP SIGNATURE-----

0
perl_dummy
2/3/2004 5:44:04 PM
perl.qa 2168 articles. 0 followers. Follow

9 Replies
594 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

On Tuesday, February 3, 2004, at 05:44  pm, Tels wrote:
[snip]
> This has prevented me from "converting" several huge old testsuites 
> from
> "use Test;" to "use Test::More;" because I know that I would then have 
> to
> go and add testnames to thousand of tests (e.g. all tests that test for
> number output). This is very boring, and you can bet that I will come 
> up
> with "is ($foo->baz(), 12, 'is 12');" just to shut of the warnings. 
> And bad
> testnames are like bad comments, better have none than a bad or silly
> one :)
[snip]

Since the test names are optional, is there any need to add one at all 
as you're converting?

Adrian

0
adrianh
2/3/2004 6:08:01 PM
On Tue, Feb 03, 2004 at 06:44:04PM +0100, Tels (perl_dummy@bloodgate.com) wrote:
> is there a re reason that the following warns:
> 
> 	% perl -MTest::More -le 'plan tests => 1; ok (1,1)'
> 	1..1
> 	#     You named your test '1'.  You shouldn't use numbers for your test
> 	 names.
> 	#     Very confusing.

ok() is not a comparison.  is() is a comparison.

xoa

-- 
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
0
andy
2/3/2004 6:26:22 PM
=2D----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Tuesday 03 February 2004 19:26, Andy Lester wrote:
> On Tue, Feb 03, 2004 at 06:44:04PM +0100, Tels (perl_dummy@bloodgate.com)=
=20
wrote:
> > is there a re reason that the following warns:
> >
> > 	% perl -MTest::More -le 'plan tests =3D> 1; ok (1,1)'
> > 	1..1
> > 	#     You named your test '1'.  You shouldn't use numbers for your
> > test names.
> > 	#     Very confusing.
>
> ok() is not a comparison.  is() is a comparison.

Under "use Test;", ok, uses "eq" to compare the first argument to the=20
second:

         ok(0,1);             # failure: '0' ne '1'
         ok('broke','fixed'); # failure: 'broke' ne 'fixed'
         ok('fixed','fixed'); # success: 'fixed' eq 'fixed'
         ok('fixed',qr/x/);   # success: 'fixed' =3D~ qr/x/

This seems to have changed in Test::More and I didn't notice that... doh!

Best wishes,

Tels

=2D --=20
 Signed on Tue Feb  3 19:35:52 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "We're looking at a future where only the very largest companies will be
 able to implement software, and it will technically be illegal for other
 people to do so." -- Bruce Perens, 2004-01-23

=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQB/qi3cLPEOTuEwVAQEmJAf+OU5S7JyLnP14qVeVnVrzJWbq6//qBCRF
98hY8m7P9XS8l80/jD4hO5VEbhhE5M+XhcGlGu8djOO1IY9Te8ti/ZRdfpfn0gpH
4k76aM0en/IrwQ50LeB7wY7vjnhAp1TdvY1ebiQL8cFRaRjGpaST5uZp6Zyd+/Zb
3NI5LV8LgABHncgSLmU5bUZE4inB6JF4lZbdCzmnO3y5Gvlh8RHdGh2MvgcKR5Ge
nxClqZ0fX8OK5jSvgVxUh/wqdfesAHiN5KvUAwA0TdhuYomC5Sb2dpfgfVXyE/FI
mYfNmrrY6zRKeLwH16BELjR0C5+3Snvytqsw9g6sVm6OcH9S3WjAEQ=3D=3D
=3D/Ig0
=2D----END PGP SIGNATURE-----

0
perl_dummy
2/3/2004 6:38:03 PM
=2D----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Tuesday 03 February 2004 19:08, Adrian Howard wrote:
> On Tuesday, February 3, 2004, at 05:44  pm, Tels wrote:
> [snip]
>
> > This has prevented me from "converting" several huge old testsuites
> > from
> > "use Test;" to "use Test::More;" because I know that I would then have
> > to
> > go and add testnames to thousand of tests (e.g. all tests that test for
> > number output). This is very boring, and you can bet that I will come
> > up
> > with "is ($foo->baz(), 12, 'is 12');" just to shut of the warnings.
> > And bad
> > testnames are like bad comments, better have none than a bad or silly
> > one :)
>
> [snip]
>
> Since the test names are optional, is there any need to add one at all
> as you're converting?

Unless I change every occurance of ok(...) to is(...), no. I was just lazy=
=20
and didn't want to change all the ok()'s for no apparent reason, but it=20
seems I must do so because Test::More's ok() differs from Test's one.

Best wishes,

Tels
>
> Adrian

=2D --=20
 Signed on Tue Feb  3 19:38:17 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Given enough time, all legal battles in the tech industry will invoke the
 DMCA. This generally means that all constructive arguments have ended."
 NialScorva's law

=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQB/q4HcLPEOTuEwVAQEDYAf/S1yZQovd6syDO+MEocLyDuFyYYzc4jih
4VNCuFUY3t8FEqbsKJSbcTWeybRyqvpOV9dvZQVhLqE1m6hupq6AnO3kawISRobx
UZEyloKtSBMuMCfz1cSbKtJNaN3UcNCZsBGbS+7bs6Vu3vCJhN1HsAtZ9roeVWA1
JzcQtMGi1EaWMA33LY/KGuaaBKI6BqKNI2nM/ZCzmDeD/bM/FygfMnQRvnwMuwF2
XT5rxmYfs2+C9+t/xbtWoX8YLDilZ8K5e4WYD0xdMChTwOjJR7EFbTFP5Dfq3FJF
M5/slJ9ULiR/UBzs0wkKonnWZnrI6nOFBhWEybAkQsljijcPSR1wog=3D=3D
=3DLHg1
=2D----END PGP SIGNATURE-----

0
tels
2/3/2004 6:39:28 PM
> If I could just change "Test;" to "Test::More;" without hundreds of warnings 
> springing on me I know I would convert the test scripts and then change 
> them step by step over to the new code (or not change them at all, because 
> don't change working code..)

If you don't mind adding a

use MyModule::OKSwapper;

after Test::More in every file then you could have

package MyModule::OKSwapper;

require Test::More;
require Exporter;
@ISA = qw( Exporter);
@EXPORT= qw( ok );

sub ok
{
	@_ = 1;
	goto &Test::More::ok;
}

Then, when you fix all the ok()s in a file, just delete the

use MyModule::OKSwapper

If you put the module in your t/MyModule/OKSwapper.pm then it won't be 
installed with make install,

F

0
fergal
2/3/2004 8:41:13 PM
=2D----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Tuesday 03 February 2004 21:41, Fergal Daly wrote:
> > If I could just change "Test;" to "Test::More;" without hundreds of
> > warnings springing on me I know I would convert the test scripts and
> > then change them step by step over to the new code (or not change them
> > at all, because don't change working code..)
>
> If you don't mind adding a
>
> use MyModule::OKSwapper;

Yup, I thought about this. But beeing lazy (and stupid) I thought I had=20
discovered a bug in Test::More.

I still think a big warning should be added to Test::More  beeing _not_ a=20
drop-in replacement to Test. After all,

	use Test::More;

	ok ($foo, 'nice');

does not test that $foo eq 'nice', which Test; does... caveat empor

Cheers,

Tels

PS: Thanx for your suggestion, but what exactly does this do:

sub ok
{
        @_ =3D 1;
        goto &Test::More::ok;
}

Pass a single (1), or only the first argument? *puzzled*
=2D --=20
 Signed on Tue Feb  3 21:44:03 2004 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Ivonna Humpalot"

=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.

iQEVAwUBQCAIvXcLPEOTuEwVAQHFJQf+M9Ksrteg5WMbxZ91yPf9ZM+qnVLo6AqW
4HYnNRGFzAEw/PuAq8yqpSbblKTrwOxLRYZJ6pDimNHiFtf+rKZ8Gw18uaN7O0uU
wc10cv+gAvib9+2voc9Jg5YEs7+Ps4K6Nn4P2pVr2g26Y3xa1rqXWSWN7DnrWdxd
wj/XiQENEJNYB6TGzvTAL8x4O3aZ/CtRXfo1Bc78pvr1r0JIKs5VQlhLLedFnuU8
9OO2A7w5stEZ1BX5Pzc3gW4Bb90FegYDdJ7rYlaSAvXkBLbR5BmlrWr9O+kPPp2A
/aYbU1DuDAPQkfqijl0bRWJnUvdxg1CGRMu6iR+Kmv8ZKgU8b9J9YQ=3D=3D
=3DrCe9
=2D----END PGP SIGNATURE-----

0
perl_dummy
2/3/2004 8:46:53 PM
On Tuesday 03 February 2004 20:46, Tels wrote:
> PS: Thanx for your suggestion, but what exactly does this do:
> 
> sub ok
> {
>         @_ = 1;
>         goto &Test::More::ok;
> }
> 
> Pass a single (1), or only the first argument? *puzzled*

It passes a single (1) :-( It should be

$#_ = 0;

I got too used to use @array as a scalar, I forgot that doesn't work for 
setting,

F

0
fergal
2/3/2004 9:05:01 PM
On Tue, 2004-02-03 at 12:46, Tels wrote:

> I still think a big warning should be added to Test::More  beeing _not_ a 
> drop-in replacement to Test.

I can only remember calling it a drop-in replacement for Test::Simple.

-- c

0
chromatic
2/3/2004 9:57:55 PM
On Tue, Feb 03, 2004 at 08:41:13PM +0000, Fergal Daly wrote:
> package MyModule::OKSwapper;
> 
> require Test::More;
> require Exporter;
> @ISA = qw( Exporter);
> @EXPORT= qw( ok );
> 
> sub ok
> {
> 	@_ = 1;
> 	goto &Test::More::ok;
> }
> 
> Then, when you fix all the ok()s in a file, just delete the

Test's ok() compares its two arguments (umm, usually).  Test::More's ok() 
simply checks if the first argument is true.  Your code above will cause all 
the ok()s to simply pass without any actual testing done.  Bad.  The test 
will run and pass but won't be testing anything.  You might as well just 
comment out all the ok() calls.

I think what you want is this:

	sub ok {
		goto &Test::More::is;
	}

Then the original intent of the tests will be performed.

However, this only emulates part of Test::ok's functionality.  It performs
a different test based on what the second argument looks like, part of the
reason I changed its behavior in Test::More--ambiguity.  So to
do it for real, you'd have to take all of these different modes of
operation into account and call ok, is, like... as appropriate.

Something like this should give a good first order approximation:

package Test::ok;

require Exporter;
@EXPORT = qw(ok);

use Test::Builder;
my $TB = Test::Builder->new;

sub ok {
    my @args = @_;

    # Run all sub references.
    for (0..1) {
        $args[$_] = $args[$_]->() if ref $args[$_] eq 'CODE';
    }

    my $result;
    if( @args == 1 ) {
        $result = $TB->ok(@args);  	# single argument == ok
    }
    elsif( $TB->maybe_regex($args[1]) ) {
        $result = $TB->like(@args);     # 2nd arg a regex == like
    }
    else {
        $result = $TB->is_eq(@args);	# everything else == is
    }

    $TB->diag($args[2]) if $args[2] and !$result;

    return $result;
}

1;


-- 
Michael G Schwern        schwern@pobox.com  http://www.pobox.com/~schwern/
Please Captain, not in front of the Klingons.
0
schwern
2/3/2004 10:56:30 PM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

What is the difference between: 'my $var = 1' vs. 'my ( $var ) = 1'?
--0016e6d9a0572cce9a0484af2d41 Content-Type: text/plain; charset=UTF-8 At the introductory level it seems like I have often seen code like this: use strict; my $var = 1; And as I review other peoples' scripts I have often encountered code like this: use strict; my ( $this, $that, $the_other ); Which I interpreted as a mechanism to declare a number of scalar variables with a minimum of typing. But lately I've been seeing this syntax and I was wondering if it was fundamentally different (and somehow more desirable): use strict; my ( $var ) = 1; As if $v...

Argument '1': cannot convert from 'object' to 'int'
 I am calling a function from a label control in my gridview.. <asp:Label ID="Label1" runat="server" Text='<%# ShowCategoriesForPID(Eval("pol_id")) %>'/> But i get following error when i compile -error CS1503: Argument '1': cannot convert from 'object' to 'int'  pol_id is an integer value and my function receives it as an integer argument.  I dont know whats wrong? The "Eval" function returns an object. To need to cast it's result: <asp:Label ID="Label1" runat="s...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Why I can't login in 'host' or 'admin' account when i upgrade to 3.1.1 from 3.1.0
Hi,I unzip DNN3.1.1 package and conver to my DNN original directory (ver 3.1.0) and install successfully.But when i login in 'host' or 'admin' account, it display 'Login Failed' ,so i tried to clean cookies in IE and also delete my portal aliases in C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\. But it still can't login by any account.Anyone have an idea what's wrong? I can't swear to this, but it seems I've had problems in the past with account resets in this situation. Have you tried logging in as Host with the default password "host"...

The type 'foo' exists in both 'one place' and 'another'
I had this error on my local development machine: Compiler Error Message: CS0433: The type 'ASP.clientredirector_ascx' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sb2\4d76034e\bec2c8d0\App_Web_clientredirector.ascx.cdcab7d2.zmdrab5k.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\sb2\4d76034e\bec2c8d0\App_Web_axhgbqrn.dll' I updated from an earlier release to the 5/8 release of WAP and did a "Convert to Web Application" on my project again, deleted the ASP.NET temp files on my local machine and double-checked that th...

[ID 20020704.001] my $foo = $1 won't taint $foo (with use re 'taint')
This is a bug report for perl from bbaetz@student.usyd.edu.au, generated with the help of perlbug 1.34 running under perl v5.8.0. ----------------------------------------------------------------- [Please enter your report here] The following test program fails with perl5.8.0RC2 and 5.6.1, but passes with 5.6.0: " #!/usr/bin/perl -wT use strict; use re 'taint'; sub is_tainted { return not eval { my $foo = join('',@_), kill 0; 1; }; } my $foo; #$foo = $0; # uncomment this to 'fix' the test #$foo = 1; print "...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

'returns' vs 'of'
I don't like the assignments of 'returns' and 'of'. I think it is easily confused. I've written foo (Int $x) returns Int in examples and nobody noticed. As formal documentation, that scans right as the outer perceived return value type. But no, it's supposed to be foo (Int $x) of Int instead. The returns keyword affects the implementation of the function, not the external contract. Yet, if returns is missing it uses the of value by default, but if the of is missing it does not give static type checking to the caller, rather than using the sam...

what does 'No overload for method 'Insert' takes '1' arguments' mean?
code that caused this error: line AddInBookSqlDataSource2.Insert(item);protected void inbookButton_Click(object sender, EventArgs e){ try{ AddInBookSqlDataSource1.Insert(); }catch (Exception ex){ uploadSPoneLabel.Text = "Saved Failed: SP One" + ex.Message; }foreach (ListItem item in authorsListBox5.Items){ try{ AddInBookSqlDataSource2.Insert(item); saveStatusLabel.Text = "Save Successful: SP Two"; }catch (Exception ex1){saveStatusLabel.Text = "Save Failed: SP Two" + ex1.Message; } } } any help appreciated Thanks in advance At a surface leve...

'IN' Clause or 'OR'
Hello, [1]: select * from TABLEA where COL1 IN('value1','value2''valu3'....) [2]:select * from TABLEA where COL1 = 'value1' OR COL1= 'value2' OR COL1='valu3'. TABLEA is a huge table and it has non-clustered index on COL1. Among the above 2 queries, which query will give me the better performance or fast response and WHY? What is the difference between 'IN' and 'OR' clauses as for as Sybase Optimization is concerned. Which is the better one to be used on huge tables. Thanks. Mac An IN list is treated ...

Web resources about - ok(1,1) vs. ok ('foo','foo') in Test::More - perl.qa

Resources last updated: 12/28/2015 8:57:37 AM