File: fallback.t

package info (click to toggle)
perl 5.8.4-8sarge6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 58,128 kB
  • ctags: 31,422
  • sloc: perl: 224,262; ansic: 155,398; sh: 32,253; pascal: 7,747; lisp: 6,121; makefile: 2,341; cpp: 2,035; yacc: 1,019; java: 23
file content (55 lines) | stat: -rwxr-xr-x 1,147 bytes parent folder | download
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
#!/usr/bin/perl -w

# test 'fallback' for overload cos/sin/atan2/exp

use Test;
use strict;

BEGIN
  {
  $| = 1;
  # to locate the testing files
  my $location = $0; $location =~ s/fallback.t//i;
  if ($ENV{PERL_CORE})
    {
    # testing with the core distribution
    @INC = qw(../t/lib);
    }
  unshift @INC, qw(../lib);     # to locate the modules
  if (-d 't')
    {
    chdir 't';
    require File::Spec;
    unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
    }
  else
    {
    unshift @INC, $location;
    }
  print "# INC = @INC\n";

  plan tests => 8;
  }

# The tests below test that cos(BigInt) = cos(Scalar) which is DWIM, but not
# exactly right, ideally cos(BigInt) should truncate to int() and cos(BigFLoat)
# should calculate the result to X digits accuracy. For now, this is better
# than die()ing...

use Math::BigInt;
use Math::BigFloat;

my $bi = Math::BigInt->new(1);

ok (cos($bi), cos(1));
ok (sin($bi), sin(1));
ok (exp($bi), exp(1));
ok (atan2($bi,$bi), atan2(1,1));

my $bf = Math::BigInt->new(1);

ok (cos($bf), cos(1));
ok (sin($bf), sin(1));
ok (exp($bf), exp(1));
ok (atan2($bf,$bf), atan2(1,1));