File: as_int64.t

package info (click to toggle)
libmath-int64-perl 0.54-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 672 kB
  • ctags: 924
  • sloc: perl: 2,805; ansic: 320; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

use strict;
use warnings;

use Math::Int64 qw(uint64 int64);

package Thing;

sub new {
    my ($class, $n) = @_;
    my $self = { n => $n };
    bless $self, $class;
}

sub as_int64 {
    my $self = shift;
    $self->{n} * 2;
}

sub as_uint64 {
    my $self = shift;
    $self->{n} * 3;
}

package main;



use Test::More 0.88;

my $t = Thing->new(4);

my $u = uint64(2);
my $i = int64(2);

ok($u * $t == 24);
ok($i * $t == 16);

$t = Thing->new($u);

ok($u * $t == 12);
ok($i * $t == 8);

done_testing();