Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Stupidest Prime Number detector ever!! [*.t naming convention]

by kcott (Archbishop)
on Jun 24, 2021 at 03:34 UTC ( [id://11134238]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Stupidest Prime Number detector ever!! (updated)
in thread Stupidest Prime Number detector ever!!

G'day AnomalousMonk,

"The naming convention for SomeModule.pm test code is SomeModule.t. This is not enforced in any way, but it's what everyone expects."

I have never encountered that convention — where have you seen it? I certainly wouldn't expect it; I've mostly seen test files starting with numbers and are all lowercase (e.g. nn-name.t).

A t/ directory I'd create for an OO module might look something like:

00-load.t # test 'use' 01-instantiate.t # test 'new()' 02-some_func.t # test 'some_func()' ... # and so on ...

And, as a real world example, here's part of the output of make test for a $work module I ran in the last hour:

t/00-load.t ............... ok t/01-instantiate.t ........ ok t/02-overload.t ........... ok t/03-validation.t ......... ok ...

Just in case I was having a sudden, and unexpected, mental breakdown, I checked a few arbitrary, but well-known, CPAN modules' t/ directories:

Module Repo t/
Text::CSV https://github.com/makamaka/Text-CSV/tree/master/t
JSON https://github.com/makamaka/JSON/tree/master/t
DBI https://github.com/perl5-dbi/dbi/tree/master/t
XML::LibXML https://github.com/shlomif/perl-XML-LibXML/tree/master/t

As you can see, for the most part they all follow the same basic naming convention (i.e. number, name, .t). There are a few exceptions (e.g. pod.t) but there are none that look like your SomeModule.t.

— Ken

Replies are listed 'Best First'.
Re^4: Stupidest Prime Number detector ever!! [*.t naming convention]
by eyepopslikeamosquito (Archbishop) on Jun 24, 2021 at 10:48 UTC

    > I have never encountered that convention — where have you seen it? I certainly wouldn't expect it; I've mostly seen test files starting with numbers and are all lowercase (e.g. nn-name.t).

    Yes. Strongly agree.

    Here's another convention I'm sure you'd expect and approve of: convert a haiku (three lines of 5-7-5 syllables) into the test names, so as to entertain the bored tester (or AI robot) by gradually revealing an inspiring haiku as the test suite runs. For example, this haiku:

    Coffee mug shatters
    Larry Apocalyptic
    Parrot not a hoax

    Gallop Ponie bold!
    Beer to gulp, Buffy astride
    Orange sky surrounds

    can be easily converted into a CPAN test suite to display:

    t/00_Coffee.t ....... ok t/01_mug.t .......... ok t/02_shatters.t ..... ok t/03_Larry.t ........ ok t/04_Apocalyptic.t .. ok t/05_Parrot.t ....... ok t/06_not.t .......... ok t/07_a.t ............ ok t/08_hoax.t ......... ok t/09_Gallop.t ....... ok t/10_Ponie.t ........ ok t/11_bold.t ......... ok t/12_Beer.t ......... ok t/13_to.t ........... ok t/14_gulp.t ......... ok t/15_Buffy.t ........ ok t/16_astride.t ...... ok t/17_Orange.t ....... ok t/18_sky.t .......... ok t/19_surrounds.t .... ok

    What? I'm the only one using that convention? Really?

    Seeing it again after so many years, it's looking a bit dated, composed during the early Perl 6 era, and heavily influenced by London.pm culture I see. Probably should compose a new one.

Re^4: Stupidest Prime Number detector ever!! [*.t naming convention]
by choroba (Cardinal) on Jun 24, 2021 at 12:34 UTC
    > I have never encountered that convention — where have you seen it?

    Interestingly, we use it at work for 1K+ libraries that drive our product.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134238]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found