[svn:parrot] r41173 - in trunk: src/pmc t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed Sep 9 15:04:01 UTC 2009
Author: NotFound
Date: Wed Sep 9 15:03:58 2009
New Revision: 41173
URL: https://trac.parrot.org/parrot/changeset/41173
Log:
[cage] simplify FPA.get_repr and improve his test
Modified:
trunk/src/pmc/fixedpmcarray.pmc
trunk/t/pmc/fixedpmcarray.t
Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc Wed Sep 9 10:40:42 2009 (r41172)
+++ trunk/src/pmc/fixedpmcarray.pmc Wed Sep 9 15:03:58 2009 (r41173)
@@ -189,12 +189,10 @@
for (i = 0; i < n; ++i) {
PMC * const val = SELF.get_pmc_keyed_int(i);
+ if (i > 0)
+ res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ", "));
res = Parrot_str_append(INTERP, res, VTABLE_get_repr(INTERP, val));
- if (n == 1)
- res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ","));
- else if (i < n - 1)
- res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ", "));
}
res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, ")"));
Modified: trunk/t/pmc/fixedpmcarray.t
==============================================================================
--- trunk/t/pmc/fixedpmcarray.t Wed Sep 9 10:40:42 2009 (r41172)
+++ trunk/t/pmc/fixedpmcarray.t Wed Sep 9 15:03:58 2009 (r41173)
@@ -302,15 +302,34 @@
.end
.sub test_get_repr
- .local pmc fpa, n
+ .local string s, aux
+ s = get_repr_fpa_n(0)
+ aux = get_repr_fpa_n(1)
+ concat s, aux
+ aux = get_repr_fpa_n(2)
+ concat s, aux
+ aux = get_repr_fpa_n(3)
+ concat s, aux
+ like(s,'\(\)\(0\)\(0\,\s*1\)\(0\,\s*1\,\s*2\)','get_repr')
+.end
+
+.sub get_repr_fpa_n
+ .param int n
+ .local int i
+ .local pmc fpa, p
.local string s
fpa = new ['FixedPMCArray']
- fpa = 2
- n = box 1
- fpa[0] = n
- fpa[1] = n
+ fpa = n
+ i = 0
+next:
+ if i == n goto done
+ p = box i
+ fpa[i] = p
+ inc i
+ goto next
+done:
s = get_repr fpa
- like(s,'1\,\s*1','get_repr')
+ .return(s)
.end
.sub test_splice_oob
More information about the parrot-commits
mailing list