File: overload_switch.t

package info (click to toggle)
libmath-mpfr-perl 4.45-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,716 kB
  • sloc: perl: 1,508; ansic: 517; makefile: 9
file content (46 lines) | stat: -rwxr-xr-x 1,314 bytes parent folder | download | duplicates (3)
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
# This file created in response to:
# https://github.com/sisyphus/math-decimal64/pull/1,
# which also applies to Math::MPFR
# Thanks to @hiratara

use strict;
use warnings;
use Math::MPFR;

use Test::More;

END { done_testing(); };

my $two = Math::MPFR->new(2);

cmp_ok($two - 7, '==', -5, "Math::MPFR object - IV");
cmp_ok(5 - $two, '==',  3, "IV - Math::MPFR object");

cmp_ok($two / 2, '==', 1, "Math::MPFR object / IV");
cmp_ok(8 / $two, '==', 4, "IV / Math::MPFR object");

cmp_ok($two ** 6, '==', 64, "Math::MPFR object ** IV");
cmp_ok(6 ** $two, '==', 36, "IV ** Math::MPFR object");

cmp_ok($two, '>', 1, "Math::MPFR object > IV");
cmp_ok(4, '>', $two, "IV > Math::MPFR object");

cmp_ok($two, '>=', 1, "Math::MPFR object >= IV");
cmp_ok(4, '>=', $two, "IV >= Math::MPFR object");

cmp_ok($two, '<', 6,  "Math::MPFR object < IV");
cmp_ok(-4, '<', $two, "IV < Math::MPFR object");

cmp_ok($two, '<=', 6,  "Math::MPFR object <= IV");
cmp_ok(-4, '<=', $two, "IV <= Math::MPFR object");

cmp_ok($two <=> 6, '<', 0, "Math::MPFR object <=> IV");
cmp_ok(6 <=> $two, '>', 0, "IV <=> Math::MPFR object");


# These next 2 subs will cause failures here on perl-5.20.0
# and later if &PL_sv_yes or &PL_sv_no is encountered in the
# overload sub.

sub foo () {!0} # Breaks PL_sv_yes
sub bar () {!1} # Breaks PL_sv_no