#385: t/pmc/packfileconstanttable.t failure
--------------------+-------------------------------------------------------
Reporter: coke | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: none | Version:
Severity: medium | Keywords:
Lang: | Patch:
Platform: |
--------------------+-------------------------------------------------------
Comment(by jkeenan):
Replying to [comment:3 jkeenan]:
I got that test to pass at r37042. Given that r37043 dealt with
Parrotbug, that makes me quite certain that the bug crept in in r37044.
However, I wonder whether the problem may be that the test was not updated
properly when François began to yank the Random PMC (rather than the
yanking itself). Here's what was done in r37044:
{{{
$ svn diff -r 37043:37044 .
Index: runtime/parrot/library/uuid.pir
===================================================================
--- runtime/parrot/library/uuid.pir (revision 37043)
+++ runtime/parrot/library/uuid.pir (revision 37044)
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, Parrot Foundation.
+# Copyright (C) 2008-2009, Parrot Foundation.
# $Id$
=head1 NAME
@@ -22,6 +22,7 @@
.namespace ['uuid']
.sub '__onload' :anon :load :init
+ load_bytecode 'Math/Rand.pbc'
$P0 = subclass 'FixedIntegerArray', 'uuid'
.end
@@ -96,16 +97,23 @@
.local pmc res
new res, 'uuid'
set res, N
- new $P0, 'Random'
+ .local pmc rand
+ rand = get_hll_global [ 'Math'; 'Rand' ], 'rand'
+ .local pmc srand
+ srand = get_hll_global [ 'Math'; 'Rand' ], 'srand'
+ .local int RAND_MAX
+ $P0 = get_hll_global [ 'Math'; 'Rand' ], 'RAND_MAX'
+ RAND_MAX = $P0()
+ inc RAND_MAX
time $I0 # less than enough entropy
- set $P0, $I0
+ srand($I0)
.local int i
i = 0
L1:
unless i < N goto L2
- $N0 = $P0
- $N0 *= 256
- $I0 = floor $N0
+ $I0 = rand()
+ $I0 *= 256
+ $I0 /= RAND_MAX
res[i] = $I0
inc i
goto L1
@@ -133,16 +141,23 @@
.local pmc res
new res, 'uuid'
set res, N
- new $P0, 'Random'
- time $I0 # less than enough entropy
- set $P0, $I0
+ .local pmc rand
+ rand = get_hll_global [ 'Math'; 'Rand' ], 'rand'
+ .local pmc srand
+ srand = get_hll_global [ 'Math'; 'Rand' ], 'srand'
+ .local int RAND_MAX
+ $P0 = get_hll_global [ 'Math'; 'Rand' ], 'RAND_MAX'
+ RAND_MAX = $P0()
+ inc RAND_MAX
+ time $I0 # less than enough entropy
+ srand($I0)
.local int i
i = 10
L1:
unless i < N goto L2
- $N0 = $P0
- $N0 *= 256
- $I0 = floor $N0
+ $I0 = rand()
+ $I0 *= 256
+ $I0 /= RAND_MAX
res[i] = $I0
inc i
goto L1
}}}
And here's the failing test:
{{{
pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'get_type,
get_*_keyed_int' );
.sub 'test' :main
.local pmc pf, pfdir, pftable
.local int size, this, type
pf = _pbc()
pfdir = pf.'get_directory'()
pftable = pfdir[2]
size = elements pftable
this = 0
LOOP:
type = pftable.'get_type'(this)
eq type, 0x00, NEXT
eq type, 0x6E, CONST_NUM
eq type, 0x73, CONST_STR
eq type, 0x70, CONST_PMC
eq type, 0x6B, CONST_KEY
goto BAD
CONST_NUM:
$N0 = pftable[this]
goto NEXT
CONST_STR:
$S0 = pftable[this]
goto NEXT
CONST_PMC:
$P0 = pftable[this]
goto NEXT
CONST_KEY:
$P0 = pftable[this]
$S0 = typeof $P0
eq $S0, 'Key', NEXT
print 'constant Key with wrong type: '
say $S0
goto BAD
NEXT:
this = this + 1
ge this, size, DONE
goto LOOP
gt size, 0, DONE
BAD:
say 'unknown constant type found!'
DONE:
say 'done.'
.end
CODE
done.
OUT
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/385#comment:4>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets