blob: 57746fdcd4450c7bd6923e0b454ec9b935ff3533 (
plain)
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
|
#!./perl
#
# Regression tests for the Math::Trig package
#
# The tests are quite modest as the Math::Complex tests exercise
# these quite vigorously.
#
# -- Jarkko Hietaniemi, April 1997
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
use Math::Trig;
use strict;
use vars qw($x $y $z);
my $eps = 1e-11;
sub near ($$;$) {
abs($_[0] - $_[1]) < (defined $_[2] ? $_[2] : $eps);
}
print "1..6\n";
$x = 0.9;
print 'not ' unless (near(tan($x), sin($x) / cos($x)));
print "ok 1\n";
print 'not ' unless (near(sinh(2), 3.62686040784702));
print "ok 2\n";
print 'not ' unless (near(acsch(0.1), 2.99822295029797));
print "ok 3\n";
$x = asin(2);
print 'not ' unless (ref $x eq 'Math::Complex');
print "ok 4\n";
# avoid using Math::Complex here
$x =~ /^([^-]+)(-[^i]+)i$/;
($y, $z) = ($1, $2);
print 'not ' unless (near($y, 1.5707963267949) and
near($z, -1.31695789692482));
print "ok 5\n";
print 'not ' unless (near(deg_to_rad(90), pi/2));
print "ok 6\n";
# eof
|