re-factored conversions
parent
f092bf7aab
commit
293f503fa1
|
@ -2,6 +2,7 @@ package DDG::Goodie::Conversions;
|
|||
# ABSTRACT: convert between various weights and measures
|
||||
|
||||
# @todo: set significant digits
|
||||
# @todo: handle multi-word units
|
||||
# @todo: handle plural units
|
||||
|
||||
use DDG::Goodie;
|
||||
|
@ -11,7 +12,7 @@ use Scalar::Util qw(looks_like_number);
|
|||
# known SI units and aliases / plurals / common uses:
|
||||
my %units = (
|
||||
# metric ton:
|
||||
'metric ton' => '1',
|
||||
#'metric ton' => '1',
|
||||
'tonne' => '1',
|
||||
't' => '1',
|
||||
'mt' => '1',
|
||||
|
@ -38,12 +39,12 @@ my %units = (
|
|||
'mcg' => '1000000000',
|
||||
|
||||
# long ton:
|
||||
'long ton' => '0.984207',
|
||||
'weight ton' => '0.984207',
|
||||
'imperial ton' => '0.984207',
|
||||
#'long ton' => '0.984207',
|
||||
#'weight ton' => '0.984207',
|
||||
#'imperial ton' => '0.984207',
|
||||
|
||||
# short ton:
|
||||
'short ton' => '1.10231',
|
||||
#'short ton' => '1.10231',
|
||||
'ton' => '1.10231',
|
||||
|
||||
# stone:
|
||||
|
@ -54,7 +55,7 @@ my %units = (
|
|||
'pound' => '2204.62',
|
||||
'lb' => '2204.62',
|
||||
'lbm' => '2204.62',
|
||||
'pound mass' => '2204.62',
|
||||
#'pound mass' => '2204.62',
|
||||
|
||||
# ounce:
|
||||
'ounce' => '35274',
|
||||
|
|
|
@ -16,13 +16,14 @@ ddg_goodie_test(
|
|||
# @todo: could create a complete test suite for all toUnits->fromUnits
|
||||
|
||||
'convert 5 oz to g' => test_zci('5 oz is 141.747462720417 g',),
|
||||
'convert 1 ton to long ton' => test_zci('1 ton is 0.892858633233845 long ton',),
|
||||
#'convert 1 ton to long ton' => test_zci('1 ton is 0.892858633233845 long ton',),
|
||||
'convert 158 ounce to lbm' => test_zci('158 ounce is 9.87497760390089 lbm',),
|
||||
'convert 0.111 stone to pound' => test_zci('0.111 stone is 1.55399859023452 pound',),
|
||||
'mcg to mcg' => test_zci('1 mcg is 1 mcg',),
|
||||
'3 kilogramme to pound' => test_zci('3 kilogramme is 6.61386 pound',),
|
||||
'1.3 metric ton to short ton' => test_zci('1.3 metric ton is 1.433 short ton',),
|
||||
'1.3 tonne to ton' => test_zci('1.3 tonne is 1.433003 ton',),
|
||||
'stone pound' => test_zci('1 stone is 13.9999872994101 pound',),
|
||||
'gram pound convert' => test_zci('1 gram is 0.00220462 pound',),
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue