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":