Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • my $d = $t->get('D');
    my $blnOk = 0;
    if (!defined($d)) { $blnOk=1;}
    ok($blnOk==1, "Making sure no extra variables are created");
    That might be better written as:
    my $d = $t->get('D');
    ok(!defined($d), "Making sure no extra variables are created");

    "Cake or Death!" .... "Cake please"
    • It'd be written even better as:
      my $d = $t->get('D');
      is( $d, 'expected_value', "get(D)");

      Use of is(), like() and isa_ok() is a very good thing where possible.


  • I'm *extremely* new to testing and this post was very informative for me. Thanks.


    What is test # 7 about?

    What if 'E' exists?

    What if the object is inherited, couldn't it have a 'D'? (hmm... that wouldn't happen during testing tho... right?)

    From a philosophical view, it would seem to me that tests should cover the requirements... and I didn't see anything in the requirement to drive test 7.

    It also seems that if you wanted to check that there were not extra variables created, you would need to enume
  • ok($a==1, "Testing 1st Parameter");

    is better written as

    is( $a, 1, "Testing 1st Parameter");

    for better diagnostics on failure. Any time you're writing

    ok( $a == 1 )

    you probably want

    is( $a, 1 );

    unless your name is Nick Clark, in which case you reall, really meant '==' so its cmp_ok($a, '==', 1 ) or Damian Conway, in which case there's probably a really good reason you used ok() instead of is().

    Even better would be:

    is( $a, 1, 'getting A' );

    Mentioning that you're "testing" something in a test