This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
filecopy.t #3 fails on dos-djgpp
[perl5.git] / t / lib / trig.t
CommitLineData
5aabfad6 1#!./perl
2
3#
4# Regression tests for the Math::Trig package
5#
6# The tests are quite modest as the Math::Complex tests exercise
7# these quite vigorously.
8#
9# -- Jarkko Hietaniemi, April 1997
10
11BEGIN {
12 chdir 't' if -d 't';
13 @INC = '../lib';
14}
15
16use Math::Trig;
17
18use strict;
19
20use vars qw($x $y $z);
21
22my $eps = 1e-11;
23
24sub near ($$;$) {
25 abs($_[0] - $_[1]) < (defined $_[2] ? $_[2] : $eps);
26}
27
ace5de91 28print "1..7\n";
5aabfad6 29
30$x = 0.9;
31print 'not ' unless (near(tan($x), sin($x) / cos($x)));
32print "ok 1\n";
33
34print 'not ' unless (near(sinh(2), 3.62686040784702));
35print "ok 2\n";
36
37print 'not ' unless (near(acsch(0.1), 2.99822295029797));
38print "ok 3\n";
39
40$x = asin(2);
41print 'not ' unless (ref $x eq 'Math::Complex');
42print "ok 4\n";
43
44# avoid using Math::Complex here
45$x =~ /^([^-]+)(-[^i]+)i$/;
46($y, $z) = ($1, $2);
47print 'not ' unless (near($y, 1.5707963267949) and
48 near($z, -1.31695789692482));
49print "ok 5\n";
50
ace5de91 51print 'not ' unless (near(deg2rad(90), pi/2));
5aabfad6 52print "ok 6\n";
53
ace5de91
GS
54print 'not ' unless (near(rad2deg(pi), 180));
55print "ok 7\n";
56
5aabfad6 57# eof