Index: t/op/arithmetics_pmc.t =================================================================== --- t/op/arithmetics_pmc.t (revision 41853) +++ t/op/arithmetics_pmc.t (working copy) @@ -1,17 +1,7 @@ -#!perl +#! parrot # Copyright (C) 2001-2009, Parrot Foundation. # $Id$ -use strict; -use warnings; -use lib qw( . lib ../lib ../../lib ); - -use Test::More; -use Parrot::Test; - -# test for GMP -use Parrot::Config; - =head1 NAME t/op/arithmetics_pmc.t - Arithmetic Ops involving PMCs @@ -26,84 +16,636 @@ =cut -# We don't check BigInt and BigNum ops -if ( $PConfig{gmp} ) { - plan tests => 68; -} -else { - plan tests => 34; -} +.sub main :main + .include 'test_more.pir' + .include "iglobals.pasm" + plan(68) -# Map vtable method to op -my %methods = qw{ - add add - subtract sub - multiply mul - divide div + # Don't check BigInt or BigNum without gmp + .local pmc interp # a handle to our interpreter object. + interp = getinterp + .local pmc config + config = interp[.IGLOBALS_CONFIG_HASH] + .local int gmp + gmp = config['gmp'] - floor_divide fdiv - modulus mod - pow pow + run_tests_for('Integer') + run_tests_for('Float') - bitwise_or bor - bitwise_and band - bitwise_xor bxor + if gmp goto do_big_ones + skip( 34, "will not test BigInt or BigNum without gmp" ) + goto end - bitwise_shr shr - bitwise_shl shl - bitwise_lsr lsr + do_big_ones: + run_tests_for('BigInt') + run_tests_for('BigNum') - concatenate concat + end: +.end - logical_or or - logical_and and - logical_xor xor -}; +.sub run_tests_for + .param pmc type + test_add(type) + test_divide(type) + test_multiply(type) + test_floor_divide(type) + test_logical_and(type) + test_concatenate(type) + test_logical_xor(type) + test_logical_or(type) + test_bitwise_shr(type) + test_bitwise_or(type) + test_bitwise_shl(type) + test_bitwise_xor(type) + test_modulus(type) + test_pow(type) + test_subtract(type) + test_bitwise_lsr(type) + test_bitwise_and(type) +.end -# XXX Put BigInt and BigNum here -my @pmcs = qw{ - Integer Float -}; +.sub test_add + .param pmc type -if ($PConfig{gmp}) { - push @pmcs, qw{ BigInt BigNum}; -} + $P0 = new type + $P0 = 40 + $P1 = new type + $P1 = 2 + $P2 = new type + $P2 = 115200 -foreach my $pmc (@pmcs) { - while(my($vtable, $op) = each(%methods)) { + $P99 = $P2 -# We should generate more tests for all possible combinations -pir_output_is( <<"CODE", < 1; -} -else { - plan skip_all => "64bit INTVAL platforms only"; -} +.sub main :main + .include "iglobals.pasm" + .include 'test_more.pir' -pasm_output_is( <<'CODE', <<'OUTPUT', "bitops64" ); + # Check to see if this is 64 bit + .local pmc interp # a handle to our interpreter object. + interp = getinterp + .local pmc config + config = interp[.IGLOBALS_CONFIG_HASH] + .local int intvalsize + intvalsize = config['intvalsize'] + + plan(5) + + if intvalsize == 8 goto is_64_bit + skip(5, "this is not a 64 bit platform") + goto end + + is_64_bit: + bitops64() + + end: +.end + + +.sub bitops64 # check bitops for 8-byte ints - set I0, 0xffffffffffffffff - print I0 # -1 - print "\n" - set I1, 0x00000000ffffffff - print I1 # 4294967295 - print "\n" - set I0, I1 - shl I0, I0, 32 - print I0 # -4294967296 - print "\n" - band I2, I0, I1 - print I2 # 0 - print "\n" - bor I2, I0, I1 - print I2 # -1 - print "\n" - end -CODE --1 -4294967295 --4294967296 -0 --1 -OUTPUT + set $I0, 0xffffffffffffffff + is( $I0, -1 ) + + set $I1, 0x00000000ffffffff + is( $I1, 4294967295 ) + + set $I0, $I1 + shl $I0, $I0, 32 + is( $I0, -4294967296 ) + + band $I2, $I0, $I1 + is( $I2, 0 ) + bor $I2, $I0, $I1 + is( $I2, -1 ) +.end + # Local Variables: -# mode: cperl +# mode: pir # cperl-indent-level: 4 # fill-column: 100 # End: -# vim: expandtab shiftwidth=4: +# vim: expandtab shiftwidth=4 ft=pir: Index: t/op/arithmetics.t =================================================================== --- t/op/arithmetics.t (revision 41853) +++ t/op/arithmetics.t (working copy) @@ -1,17 +1,7 @@ -#!perl -# Copyright (C) 2001-2009, Parrot Foundation. +#! parrot +# Copyright (C) 2001-2008, Parrot Foundation. # $Id$ -use strict; -use warnings; -use lib qw( . lib ../lib ../../lib ); - -use Test::More; -use Parrot::Test tests => 21; - -# test for GMP -use Parrot::Config; - =head1 NAME t/op/arithmetics.t - Arithmetic Ops @@ -27,577 +17,513 @@ =cut +.sub main :main + .include 'test_more.pir' + + plan(125) + + take_the_negative_of_a_native_integer() + take_the_absolute_of_a_native_integer() + add_native_integer_to_native_integer() + subtract_native_integer_from_native_integer() + multiply_native_integer_with_native_integer() + divide_native_integer_by_native_integer() + negate_minus_zero_point_zero() + negate_a_native_number() + take_the_absolute_of_a_native_number() + ceil_of_a_native_number() + floor_of_a_native_number() + add_native_integer_to_native_number() + subtract_native_integer_from_native_number() + multiply_native_number_with_native_integer() + divide_native_number_by_native_integer() + add_native_number_to_native_number() + subtract_native_number_from_native_number() + multiply_native_number_with_native_number() + divide_native_number_by_native_number() + lcm_test() + integer_overflow_with_pow() + # END_OF_TESTS + +.end + # # Operations on a single INTVAL # -pasm_output_is( <<'CODE', < 40 goto next + + end: .end -CODE -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 -65536 -131072 -262144 -524288 -1048576 -2097152 -4194304 -8388608 -16777216 -33554432 -67108864 -134217728 -268435456 -536870912 -1073741824 -2147483648 -4294967296 -8589934592 -17179869184 -34359738368 -68719476736 -137438953472 -274877906944 -549755813888 -1099511627776 -OUTPUT -} - # Local Variables: -# mode: cperl +# mode: pir # cperl-indent-level: 4 # fill-column: 100 # End: -# vim: expandtab shiftwidth=4: +# vim: expandtab shiftwidth=4 ft=pir :