Astro-Catalog
view release on metacpan or search on metacpan
t/2_jcmt_loose.t view on Meta::CPAN
#!perl
# Test that we can read a JCMT catalog that is not rigid about its
# columns. Test simply creates a catalog with random junk attached
# and then reads it in and compares target values.
use strict;
use Test::More tests => 13;
require_ok('Astro::Coords');
require_ok('Astro::Catalog::Item');
require_ok('Astro::Catalog');
# test sources
my @input = (
{
ra => '03:25:27.1',
dec => '30:45:11',
type => 'j2000',
name => 'a space',
comment => 'with comment'
},
{
ra => '13:25:27.1',
dec => '-30:45:11',
type => 'b1950',
name => 'test',
},
{
long => '03:26:30.0',
lat => '-1:45:0',
type => 'galactic',
name => 'gal 2',
},
);
# Start by having some test coordinates
# convert test sources to Astro::Coords and randomly
my @ref = map {
new Astro::Coords(units => 'sex', %$_);
} @input;
# Make sure we have constructed objects
for (@ref) {
isa_ok($_, "Astro::Coords::Equatorial");
}
# Generate a catalog manually
my @lines = ("* a comment\n");
for my $c (@ref) {
my $line = $c->name;
my $ra = $c->ra(format => 's');
my $dec = $c->dec( format => 's');
$ra =~ s/:/ /g;
$dec =~ s/:/ /g;
$line .= "$ra $dec ";
# Always RJ
$line .= "rj ";
if (rand(1) < 0.5) {
# add some extra stuff
( run in 2.630 seconds using v1.01-cache-2.11-cpan-364913b4093 )