#!/usr/bin/env perl use strict; use warnings; use lib 'blib/lib'; our $VERSION = '0.01'; use Test::More; use Math::AnyInt; $Math::AnyInt::VERBOSE_AnyInt = 1; my @tests = ( # left-operand, operator, right-operand, expected result in JS [1, '+', 2, 3], [1169367104, '<<', 5, -1234958336], [1073741824, '+', 1073741824, 2147483648], ); for my $at (@tests){ my ($lop, $op, $rop, $expected) = @$at; my $LOP = Math::AnyInt->new($lop); is($$LOP, $lop, 'Math::AnyInt->new()'." : called and contains value '$lop'."); my $ROP = Math::AnyInt->new($rop); is($$ROP, $rop, 'Math::AnyInt->new()'." : called and contains value '$rop'."); my $result = Math::AnyInt::calcop($LOP, $op, $ROP); is($$result, $expected, "$lop $op $rop : got $result, expected $expected."); } # test addition of two integers by taking it in C via Inline::C # and using C's int32_t (NERDVANA) is(Math::AnyInt::test_addition_in_C(1073741824, 1073741824), 2147483648, "Testing NERDVANA's C additon calc()"); # END done_testing();