Astro-Constants

 view release on metacpan or  search on metacpan

script/add_constant.pl  view on Meta::CPAN

	my $ans = <STDIN>;
	$add_constant = 0 unless $ans =~ /^y/i; 
}

write_entries();

exit;

sub populate_fields {
    get_name();
    check_not_a_duplicate() or return;
    get_description();
    get_value();
    get_precision();
    get_dimensions();
    get_source();
    get_categories();
}

sub get_constant_definition {
	do {

script/add_constant.pl  view on Meta::CPAN

	print "\nGive a list of categories the constant belongs to, separated by commas ";
	my $cat = <STDIN>;
	chomp $cat;
	@categories = grep { exists $category{$_} } split /\s*,\s*/, $cat;
	$category_list = join ", ", @categories;

	# a default
	@categories = qw/unclassified/ unless scalar @categories;
}

sub check_not_a_duplicate {
    my @constants = $xml->getElementsByTagName('PhysicalConstant');
    for my $node (@constants) {
        if ($node->getChildrenByTagName('name') eq $name) {
            warn "$name already exists.  Skipping\n";
            return;
        }
    }
    return 1; # no duplicates
}

t/warnings.t  view on Meta::CPAN

use Test2::V0;

use Astro::Constants qw( HUBBLE_TIME );
#use Astro::Constants qw( :deprecated );

#imported_ok('HUBBLE_TIME');
#not_imported_ok('HUBBLE_TIME2');

ok warns { HUBBLE_TIME }, 'Deprecated constant emits a warning';
like(
    warning { HUBBLE_TIME },
    qr/^HUBBLE_TIME deprecated at/,
    'Got expected warning'
);

done_testing();



( run in 0.525 second using v1.01-cache-2.11-cpan-0a987023a57 )