Hello all,

Today I learned about some of the test modules in CPAN, and decided to apply Test::More to a little module (my first) that I've been playing with.

It was going well - I found some bugs, fixed them and eventually had 50 something 'ok's on my screen. Then I added another test - this one hopes to check that two arrays of hashrefs contain the same things. Since order is not important I thought an ok(equal_set()) would do the trick.

So here's a cutdown version of what I have:

#!/usr/bin/perl use warnings; use strict; use Test::More tests => 2; BEGIN { use_ok('Atoms'); } my @atoms = read_xyz("t/basic.atoms"); # Test remove duplicates my @atoms_snapshot = @atoms; foreach my $atom (@atoms_snapshot) { push @atoms, $atom; } @atoms = remove_duplicates(@atoms); use Data::Dumper; print Dumper \@atoms; print Dumper \@atoms_snapshot; ok(eq_set(\@atoms, \@atoms_snapshot), "Basic remove dups check");
and here's the output:
1..2 ok 1 - use Atoms; $VAR1 = [ { 'X' => '6E-1', 'NAME' => 'Mn', 'Y' => '-6.0E-1', 'Z' => '0.06E1' }, { 'X' => '1', 'NAME' => 'Mn', 'Y' => '1.0', 'Z' => '0.01E+2' }, { 'X' => '-0.5', 'NAME' => 'O', 'Y' => '-0.75', 'Z' => '0.666666666666667' } ]; $VAR1 = [ { 'X' => '1', 'NAME' => 'Mn', 'Y' => '1.0', 'Z' => '0.01E+2' }, { 'X' => '6E-1', 'NAME' => 'Mn', 'Y' => '-6.0E-1', 'Z' => '0.06E1' }, { 'X' => '-0.5', 'NAME' => 'O', 'Y' => '-0.75', 'Z' => '0.666666666666667' } ]; not ok 2 - Basic remove dups check # Failed test (./fake at line 22) # Looks like you failed 1 tests of 2.

I'm sure someone will be able to spot my error.

PS: I realize and you've probably realized that I've not been sufficiently lazy and used Math::VectorReal, but once I've got the tests in place, I should be able to make the changes with confidence...

Kind Regards,

brewer


In reply to Test::More - equal_set by brewer

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.