1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
use Test::Base;
plan skip_all => 'set TEST_LIVE to enable this test' unless $ENV{TEST_LIVE};
plan tests => 1 * blocks;
use WWW::Google::Calculator;
sub calc {
my $calc = WWW::Google::Calculator->new;
$calc->calc(@_);
}
filters {
input => [qw/chomp calc/],
expected => [qw/chomp/],
};
run_compare input => 'expected';
__END__
# basic tests (listed as example at http://www.google.com/help/calculator.html)
=== Addition
--- input
3+44
--- expected
3 + 44 = 47
=== subtraction
--- input
13-5
--- expected
13 - 5 = 8
=== multiplication
--- input
7*8
--- expected
7 * 8 = 56
=== division
--- input
12/3
--- expected
12 / 3 = 4
=== exponentiation (raise to a power of)
--- input
8^2
--- expected
8^2 = 64
=== modulo (finds the remainder after division)
--- input
8%7
--- expected
8 mod 7 = 1
=== X choose Y determines the number of ways of choosing a set of Y elements from a set of X elements
--- input
18 choose 4
--- expected
18 choose 4 = 3060
=== calculates the nth root of a number
--- input
5th root of 32
--- expected
5th root of 32 = 2
=== X % of Y computes X percent of Y
--- input
20% of 150
--- expected
20% of 150 = 30
=== square root
--- input
sqrt(9)
--- expected
sqrt(9) = 3
=== trigonometric functions (numbers are assumed to be radians)
--- input
sin(pi/3)
--- expected
sin(pi / 3) = 0.866025404
=== trigonometric functions (numbers are assumed to be radians) 2
--- input
tan(45 degrees)
--- expected
tan(45 degrees) = 1
=== logarithm base e
--- input
ln(17)
--- expected
ln(17) = 2.83321334
=== ogarithm base 10
--- input
log(1,000)
--- expected
log(1 000) = 3
=== factorial
--- input
5!
--- expected
5 ! = 120
=== calc with units
--- input
1 a.u./c
--- expected
(1 Astronomical Unit) / the speed of light = 8.31675359 minutes
=== units translation
--- input
300kbps in KB/s
--- expected
300 kbps = 37.5 kilobytes / second
=== multiplier (reported by Torkild Retvedt)
--- input
10^20
--- expected
10^20 = 1.0 * 10^20
=== currency
--- input
1 usd in eur
--- expected regexp
1 U.S. dollar = \S+ Euros
|