Astro-MoonPhase-Simple

 view release on metacpan or  search on metacpan

t/100-calculate_moon_phase.t  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;

our $VERSION = '0.03';

use Test::More;

use FindBin;

use lib ($FindBin::Bin, 'blib/lib');

use Data::Roundtrip qw/perl2dump no-unicode-escape-permanently/;
use Config;

use Astro::MoonPhase::Simple;

my $VERBOSITY = 10;

###### WARNING These expected values expect
# that $dt->set_time_zone('UTC'); is used
# in lib/Astro/MoonPhase/Simple.pm
############################################

###### WARNING is_deeply()
# complains when it compares reals differing
# to the very last least-significant digits.
# (because we ask it to compare, e.g. Moon angle)
# the expected results (e.g. moon angle)
# were produced on my machine and can differ
# for other machines or for Perls compiled
# differently (e.g. see -Duselongdouble and
# the bug reported https://rt.cpan.org/Ticket/Display.html?id=154401)
# Moreover, in the expected results there is an 'asString'
# which contains lots of those real numbers all mixed up
# in a string.
# This can not be fixed even with the most elaborate is_deeply()
# therefore AT THE MOMENT I will check if perl was compiled
# with -Duselongdouble and if yes I will not run the is_deeply() test
# and wait for more reports.
############################################

my @tests = (
  {
    'params' => {
	"verbosity" => $VERBOSITY,
	#"name" => "Normandy Landing",
	"date" => "1944-06-06",
	"time" => "05:00:00",
	#"timezone" => "Europe/Paris",
	"location" => {lat=>49.180000, lon=>-0.370000}
    },
    'expected' => {
  "SunAng" => "0.525348747757601",
  "MoonIllum%" => "99.5706274169997",
  "MoonAng" => "0.517536236645276",
  "MoonPhase" => "0.479127303280321",
  "phases" => {
    "First quarter" => "Tue May 30 02:06:14 1944",
    "Next New Moon" => "Tue Jun 20 19:01:26 1944",
    "New Moon" => "Mon May 22 08:14:24 1944",
    "Full moon" => "Tue Jun 06 20:59:37 1944",
    "Last quarter" => "Tue Jun 13 17:57:49 1944"
  },
  "MoonDist" => "384819.736277722",
  "SunDist" => "151813722.69074",
  "MoonPhase%" => "47.9127303280321",
  "MoonAge" => "14.1489113185288",
  "asString" => "Moon age: 14.1489113185288 days\nMoon phase: 47.9 % of cycle (birth-to-death)\nMoon's illuminated fraction: 99.6 % of full disc\nimportant moon phases around specified date 1944-06-06:\n  New Moon      = Mon May 22 08:14:24 1944\n  F...
  "MoonIllum" => "0.995706274169997"
    }
  },
  {



( run in 1.108 second using v1.01-cache-2.11-cpan-39bf76dae61 )