summaryrefslogtreecommitdiff
path: root/t/mbi_ltm_since_1.999842.t
blob: 7a68870eb2f6788954e065d2ed08fd837f4ea64a (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
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
use strict;
use warnings;
use Test::More;

BEGIN {
  plan skip_all => "requires Math::BigInt 1.999842+" unless eval { require Math::BigInt && eval($Math::BigInt::VERSION) >= 1.999842 };
  plan tests => 7;
}

use Math::BigFloat only => 'LTM';
use Math::BigInt only => 'LTM';

######## https://github.com/Perl/perl5/issues/21518

#   Failed test '$x = Math::BigFloat->new("1"); $y = Math::BigFloat->new("1"); $x >> $y;'
#   at ./t/mbi_ltm/bigfltpm.inc line 168.
#          got: '0'
#     expected: '0.5'

#   Failed test '$x = Math::BigFloat->new("123"); $y = Math::BigFloat->new("1"); $x >> $y;'
#   at ./t/mbi_ltm/bigfltpm.inc line 168.
#          got: '61'
#     expected: '61.5'

#   Failed test '$x = Math::BigFloat->new("2"); $y = Math::BigFloat->new("18.2"); $x <<= $y; $x->copy()->bfround(-9);'
#   at ./t/mbi_ltm/bigfltpm.inc line 502.
#          got: '524288.000000000'
#     expected: '602248.763144685'

#   Failed test '$x = Math::BigInt->new("+8"); $y = Math::BigInt->new("-2"); $x << $y;'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '2'
#     expected: 'NaN'

#   Failed test '$x = Math::BigInt->new("+1234"); $y = Math::BigInt->new("-3"); $x->blsft($y, 10);'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '1'
#     expected: 'NaN'

#   Failed test '$x = Math::BigInt->new("+2"); $y = Math::BigInt->new("-2"); $x >> $y;'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '8'
#     expected: 'NaN'

#   Failed test '$x = Math::BigInt->new("+1234"); $y = Math::BigInt->new("-3"); $x->brsft($y, 10);'
#   at ./t/mbi_ltm/bigintpm.inc line 202.
#          got: '1234000'
#     expected: 'NaN'

########

my ($x, $y);

$x = Math::BigFloat->new("1");
$y = Math::BigFloat->new("1");
is($x >> $y, 0);

$x = Math::BigFloat->new("123");
$y = Math::BigFloat->new("1");
is($x >> $y, 61);

$x = Math::BigFloat->new("2");
$y = Math::BigFloat->new("18.2");
$x = $x <<= $y;
$x->copy()->bfround(-9);
is($x, 524288);

$x = Math::BigInt->new("+8");
$y = Math::BigInt->new("-2");
is($x << $y, 2);

$x = Math::BigInt->new("+1234");
$y = Math::BigInt->new("-3");
$x->blsft($y, 10);
is($x, 1);

$x = Math::BigInt->new("+2");
$y = Math::BigInt->new("-2");
is($x >> $y, 8);

$x = Math::BigInt->new("+1234");
$y = Math::BigInt->new("-3");
$x->brsft($y, 10);
is($x, 1234000);