xref: /openbsd-src/gnu/usr.bin/perl/cpan/Math-BigInt/t/Math/BigFloat/Subclass.pm (revision 3d61058aa5c692477b6d18acfbbdb653a9930ff9)
1# -*- mode: perl; -*-
2
3# test subclassing Math::BigFloat
4
5package Math::BigFloat::Subclass;
6
7use strict;
8use warnings;
9
10use Math::BigFloat;
11
12our @ISA = qw(Math::BigFloat);
13
14our $VERSION = "0.09";
15
16use overload;                   # inherit overload
17
18# Global variables. The values can be specified explicitly or obtained from the
19# superclass.
20
21our $accuracy   = undef;        # or Math::BigFloat::Subclass -> accuracy();
22our $precision  = undef;        # or Math::BigFloat::Subclass -> precision();
23our $round_mode = "even";       # or Math::BigFloat::Subclass -> round_mode();
24our $div_scale  = 40;           # or Math::BigFloat::Subclass -> div_scale();
25
26BEGIN {
27    *objectify = \&Math::BigInt::objectify;
28}
29
30# We override new()
31
32sub new {
33    my $proto = shift;
34    my $class = ref($proto) || $proto;
35
36    my $self = $class -> SUPER::new(@_);
37    $self->{'_custom'} = 1;     # attribute specific to this subclass
38    bless $self, $class;
39}
40
41# Any other methods to override can go here:
42
43# sub method {
44#     ...
45# }
46
471;
48