Convert-Pluggable

 view release on metacpan or  search on metacpan

t/Convert-Pluggable.t  view on Meta::CPAN


    $result = $cp->convert(
        { 'factor' => '90', 'from_unit' => 'ps', 'to_unit' => 'watts', } );
    is( $result->{'result'}, '66194.888', 'OK' );

    $result = $cp->convert(
        {
            'factor'    => '1',
            'from_unit' => 'gigawatt',
            'to_unit'   => 'horsepower',
        }
    );
    is( $result->{'result'}, '1341022.09', 'OK' );

    $result = $cp->convert(
        {
            'factor'    => '180',
            'from_unit' => 'degrees',
            'to_unit'   => 'radians',
        }
    );
    is( $result->{'result'}, '3.142', 'OK' );

    $result = $cp->convert(
        {
            'factor'    => '270',
            'from_unit' => 'degrees',
            'to_unit'   => 'quadrants',
        }
    );
    is( $result->{'result'}, '3', 'OK' );

    $result = $cp->convert(
        { 'factor' => '180', 'from_unit' => 'degrees', 'to_unit' => 'grads', }
    );
    is( $result->{'result'}, '200', 'OK' );

    $result = $cp->convert(
        {
            'factor'    => '45',
            'from_unit' => 'newtons',
            'to_unit'   => 'pounds force',
        }
    );
    is( $result->{'result'}, '10.116', 'OK' );

    $result = $cp->convert(
        { 'factor' => '8', 'from_unit' => 'poundal', 'to_unit' => 'newtons', }
    );
    is( $result->{'result'}, '1.106', 'OK' );

    $result = $cp->convert(
        { 'factor' => '5', 'from_unit' => 'f', 'to_unit' => 'celsius', } );
    is( $result->{'result'}, '-15', 'OK' );

    $result = $cp->convert(
        { 'factor' => '6^2', 'from_unit' => 'oz', 'to_unit' => 'grams', } );
    is( $result->{'result'}, '1020.582', 'OK' );

    $result = $cp->convert(
        { 'factor' => 'NaN', 'from_unit' => 'oz', 'to_unit' => 'stones', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => '45x10', 'from_unit' => 'oz', 'to_unit' => 'stones', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => '-9', 'from_unit' => 'g', 'to_unit' => 'ozs', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => '5', 'from_unit' => 'oz', 'to_unit' => 'yards', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => 'Inf', 'from_unit' => 'oz', 'to_unit' => 'stones', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        {
            'factor'    => '-5',
            'from_unit' => 'kelvin',
            'to_unit'   => 'fahrenheit',
        }
    );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => 'use', 'from_unit' => 'ton', 'to_unit' => 'stones', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => 'shoot', 'from_unit' => 'oneself', 'to_unit' => 'foot', }
    );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => 'foot', 'from_unit' => 'both', 'to_unit' => 'camps', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => 'puff', 'from_unit' => 'toke', 'to_unit' => 'kludge', } );
    is( $result->{'result'}, undef, 'OK' );

    $result = $cp->convert(
        { 'factor' => '10', 'from_unit' => 'milligrams', 'to_unit' => 'tons', }
    );
    is( $result->{'result'}, 0, '10 milligrams is 1.1e-08 tons' );

    $result = $cp->convert(
        {
            'factor'    => '10000',
            'from_unit' => 'minutes',
            'to_unit'   => 'microseconds',
        }
    );
    is( $result->{'result'}, '600000000000',
        '10000 minutes is 6e+11 microseconds' );

    $result = $cp->convert(



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