Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-20 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found