Bug in Integer PMC (i_multiply)
Nolan L
nol888 at gmail.com
Fri Dec 10 05:31:47 UTC 2010
While increasing the code coverage for the Integer PMC unit tests, I
discovered what appeared to be a bug in one of the multiply routines that is
called when using `mul $P0, $P1'.
The i_multiply VTABLE method is supposed to perform an in-place multiply on
the first operand, but when used with the BigInt and Complex PMCs as the
second operand, no multiplication is performed. Note that this works fine
when using another PMC, i.e. the Float PMC, as the second operand.
Attached is a short snippet of new tests I wrote, all using the same mul
opcode. Note that one of the three works correctly, while the other two do
not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20101210/93bfcf22/attachment.html>
-------------- next part --------------
#!./parrot
.sub 'test' :main
.include 'test_more.pir'
plan(3)
$P0 = new ['Integer']
$P1 = new ['BigInt']
$P0 = 24
$P1 = 2
mul $P0, $P1
is($P0, 48, "i_multiply Integer PMC by BigInt PMC")
$P0 = new ['Integer']
$P1 = new ['Complex']
$P0 = 2
$P1 = "2+4i"
mul $P0, $P1
is($P0, "4+8i", 'i_multiply Integer PMC by Complex PMC')
$P0 = new ['Integer']
$P1 = new ['Float']
$P0 = 2
$P1 = 3.5
mul $P0, $P1
is($P0, 7, 'i_multiply Integer PMC by DEFAULT')
.end
# Output:
#
# 1..3
# not ok 1 - i_multiply Integer PMC by BigInt PMC
# Have: 24
# Want: 48
# not ok 2 - i_multiply Integer PMC by Complex PMC
# Have: 2
# Want: 4+8i
# ok 3 - i_multiply Integer PMC by DEFAULT
More information about the parrot-dev
mailing list