Astro-Units
view release on metacpan or search on metacpan
#!/usr/bin/perl -w
use warnings;
use strict;
use lib '../lib';
use bignum;
use Test::More tests => 67;
use Astro::Units;
my $astro_kl = new Astro::Units();
my $astro_mi = new Astro::Units(unit =>'mi');
ok ($astro_kl->VERSION eq '1.10', 'Vesion Test');
ok ($astro_kl->get_astronomical_units(1) eq '149597870.7',"get_astronomical_units");
ok ($astro_kl->get_light_years(1) eq '9460730472580.8','get_light_years');
ok ($astro_kl->get_light_week(1) eq '181314478598.3999','get_light_week');
ok ($astro_kl->get_light_days(1) eq '25902068371.199997','get_light_days');
ok ($astro_kl->get_light_hours(1) eq '1079252848.8','get_light_hours');
ok ($astro_kl->get_light_minutes(1) eq '17987547.48','get_light_minutes');
ok ($astro_kl->get_light_seconds(1) eq '299792.458','get_light_seconds');
ok ($astro_kl->get_light_parsecs(1) eq '30856775814914.21805','get_light_parsecs');
ok ($astro_mi->get_astronomical_units(1) eq '92955807.27302',"get_astronomical_units");
ok ($astro_mi->get_light_years(1) eq '5878625373183.607730851','get_light_years');
ok ($astro_mi->get_light_week(1) eq '112663593736.57832011055436','get_light_week');
ok ($astro_mi->get_light_days(1) eq '16094799105.22548131412550703','get_light_days');
ok ($astro_mi->get_light_hours(1) eq '670616629.384395','get_light_hours');
ok ($astro_mi->get_light_minutes(1) eq '11176943.823073','get_light_minutes');
ok ($astro_mi->get_light_seconds(1) eq '186282.397051','get_light_seconds');
ok ($astro_mi->get_light_parsecs(1) eq '19173511576713.380141225244571701','get_light_parsecs');
ok( $astro_kl->convert_to_astronomical_units(1) eq '0.000000006684587122','convert_to_astronomical_units');
ok( $astro_kl->convert_to_light_years('1234,56,789.12_3465679_45_45mile') eq '0.000013049392906950429826613835528','convert_to_light_years');
ok( $astro_kl->convert_to_light_weeks('1') eq '0.0000000000055152793518213','convert_to_light_weeks');
ok( $astro_kl->convert_to_light_days("1") eq '0.000000000038606955462749084','convert_to_light_days');
ok( $astro_kl->convert_to_light_hours('1') eq '0.0000000009265669311', 'convert_to_light_hours');
ok( $astro_kl->convert_to_light_minutes('-1') eq '-0.00000005559401586', 'convert_to_light_minutes');
ok( $astro_kl->convert_to_light_seconds(00) eq '0', 'convert_to_light_seconds');
ok( $astro_kl->convert_to_light_parsec(-100) eq '-0.000000000003240779289444307756' ,'convert_to_light_parsec');
ok ($astro_mi->convert_to_astronomical_units(1) eq '0.000000010757800177',"convert_to_astronomical_units");
ok ($astro_mi->convert_to_light_years('1234,56,789.12_3465679_45_45mile') eq '0.00002100096217844323253888201652400031767894','convert_to_light_years');
ok ($astro_mi->convert_to_light_weeks("1") eq '0.000000000008875981733177498','convert_to_light_weeks');
ok ($astro_mi->convert_to_light_days(1) eq '0.000000000062131872132242462','convert_to_light_days');
ok ($astro_mi->convert_to_light_hours('1') eq '0.00000000149116493117','convert_to_light_hours');
ok ($astro_mi->convert_to_light_minutes('-1') eq '-0.00000008946989587','convert_to_light_minutes');
ok ($astro_mi->convert_to_light_seconds(00) eq '0','convert_to_light_seconds');
ok ($astro_mi->convert_to_light_parsec(-100) eq '-0.000000000005215528704791460021','convert_to_light_parsec');
ok( $astro_kl->au_to_light_years(1) eq '0.00001581250740982','au_to_light_years');
ok( $astro_kl->au_to_light_weeks(1) eq '0.0008250740473481426','au_to_light_weeks');
ok( $astro_kl->au_to_light_days(1) eq '0.0057755183314369961','au_to_light_days');
ok( $astro_kl->au_to_light_hours(1) eq '0.138612439954','au_to_light_hours');
ok( $astro_kl->au_to_light_minutes(1) eq '8.316746397', 'au_to_light_minutes');
ok( $astro_kl->au_to_light_seconds(1) eq '499.00478383', 'au_to_light_seconds');
ok( $astro_kl->au_to_light_parsecs(1) eq '0.000004848136811095274265', 'au_to_light_parsecs');
ok( $astro_kl->au_to_light_years(1) eq '0.00001581250740982','au_to_light_years');
ok( $astro_mi->au_to_light_weeks(1) eq '0.0008250740473481426','au_to_light_weeks');
ok( $astro_mi->au_to_light_days(1) eq '0.0057755183314369961','au_to_light_days');
ok( $astro_mi->au_to_light_hours(1) eq '0.138612439954','au_to_light_hours');
ok( $astro_mi->au_to_light_minutes(1) eq '8.316746397', 'au_to_light_minutes');
ok( $astro_mi->au_to_light_seconds(1) eq '499.00478383', 'au_to_light_seconds');
ok( $astro_mi->au_to_light_parsecs(1) eq '0.000004848136811095274265', 'au_to_light_parsecs');
ok( $astro_kl->light_years_to_au(1) eq '63241.07708426628026','light_years_to_au');
ok( $astro_kl->light_weeks_to_au(1) eq '1212.0124287196816364846','light_weeks_to_au');
ok( $astro_kl->light_days_to_au(1) eq '173.1446326742403092238665','light_days_to_au');
ok( $astro_kl->light_hours_to_au(1) eq '7.21435969476','light_hours_to_au');
ok( $astro_kl->light_minutes_to_au(1) eq '0.12023932824', 'light_minutes_to_au');
ok( $astro_kl->light_seconds_to_au(1) eq '0.0020039888041', 'light_seconds_to_au');
ok( $astro_kl->light_parsecs_to_au(1) eq '206264.80624710000000020053761', 'light_parsecs_to_au');
ok( $astro_mi->light_years_to_au(1) eq '63241.07708426628026','light_years_to_au');
ok( $astro_mi->light_weeks_to_au(1) eq '1212.0124287196816364846','light_weeks_to_au');
ok( $astro_mi->light_days_to_au(1) eq '173.1446326742403092238665','light_days_to_au');
ok( $astro_mi->light_hours_to_au(1) eq '7.21435969476','light_hours_to_au');
ok( $astro_mi->light_minutes_to_au(1) eq '0.12023932824', 'light_minutes_to_au');
ok( $astro_mi->light_seconds_to_au(1) eq '0.0020039888041', 'light_seconds_to_au');
ok( $astro_mi->light_parsecs_to_au(1) eq '206264.80624710000000020053761', 'light_parsecs_to_au');
#more test
my $string1 = '99999999998888888888999999999988888888889999999999888888888899999999998888888888675444999999999988888888889999999999888888888899999999998888888888999999999988888888886754449999999999888888888899999999998,888,888888999999999988888888899...
my $string1_out_kl ='1495978706983378014368328865229833780143683288652298337801436832886522983378014363473591537496149833780143683288652298337801436832886522983378014368328865229833780143634735915374961498337801436832886522983378014368328865229833780...
my $string1_out_mi ='9295580727199268859661631479844171166286905028709202866518512094906514600843662781068507028305631572741090054635008415464943708945300215388245237614387385355982189908650580083406415895779904338866560057907930276984466125513462504...
my $string2 ='1ww,,,,wWWW_, ____________________ ,,,,'; #bad input
my $string3 = '9999999.9998888888888999999999988888888889999999999888888888899999999998888888888675444999999999988888888889999999999888888888899999999998888888888999999999988888888886754449999999999888888888899999999998,888,88888899999999998888888889...
my $string3_out_kl ='1495978706983378.01436832886522983378014368328865229833780143683288652298337801436347359153749614983378014368328865229833780143683288652298337801436832886522983378014363473591537496149833780143683288652298337801436832886522983378...
my $string3_out_mi ='929558072719926.885966163147984417116628690502870920286651851209490651460084366278106850702830563157274109005463500841546494370894530021538824523761438738535598218990865058008340641589577990433886656005790793027698446612551346250...
ok ($astro_kl->get_astronomical_units($string1) eq $string1_out_kl,"get_astronomical_units");
ok ($astro_kl->get_astronomical_units($string3) eq $string3_out_kl,"get_astronomical_units");
ok ($astro_kl->get_light_years($string2) eq '9460730472580.8','get_light_years');
ok ($astro_mi->get_astronomical_units($string1) eq $string1_out_mi,"get_astronomical_units");
ok ($astro_mi->get_astronomical_units($string3) eq $string3_out_mi,"get_astronomical_units");
ok ($astro_mi->get_light_years($string2) eq '5878625373183.607730851','get_light_years');
done_testing();
( run in 2.867 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )