Once again, I am creating a zoo of OO Perl modules from scratch, and given the opportunity I am using test Driven Development (TDD), which I have to say is a great way to code.

Having built three OO modules so far, I am running into a problem. I want to test creating objects with as many different combinations as possible, and my general test plan is

Ideally this leaves things exactly the way they started, which means I can run the tests over and over, without stopping to clean up afterwards.

I'd like to try lots of different choices when I create the objects, and later test that all of the choics I made were correctly stored in the instantied object. The two methods I can think of for doing that are 1. nested loops, and 2. a single loop that increments a number, along with a series of tests inside the loop that checks for a particular bit and, if set, enables that particular option.

Aside: Hmm, maybe the way I should be doing it is create a named object in one scope, and then immediately test the named object in another scope, all inside one loop ..

Neither of these seem very elegant .. I did find Math::Combinatorics on CPAN but that's not really want I'm looking for. Has anyone else come across this particular challenge?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


In reply to Testing and combinations by talexb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.