[svn:parrot] r46367 - in trunk: src/pmc t/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Thu May 6 16:07:46 UTC 2010
Author: coke
Date: Thu May 6 16:07:46 2010
New Revision: 46367
URL: https://trac.parrot.org/parrot/changeset/46367
Log:
Add push_pmc to StringBuilder
Modified:
trunk/src/pmc/stringbuilder.pmc
trunk/t/pmc/stringbuilder.t
Modified: trunk/src/pmc/stringbuilder.pmc
==============================================================================
--- trunk/src/pmc/stringbuilder.pmc Thu May 6 16:02:33 2010 (r46366)
+++ trunk/src/pmc/stringbuilder.pmc Thu May 6 16:07:46 2010 (r46367)
@@ -184,6 +184,10 @@
SELF.push_string(VTABLE_get_string(INTERP, p));
}
+ VTABLE void push_pmc(PMC *p) {
+ SELF.push_string(VTABLE_get_string(INTERP, p));
+ }
+
/*
=item C<VTABLE set_string_native()>
Modified: trunk/t/pmc/stringbuilder.t
==============================================================================
--- trunk/t/pmc/stringbuilder.t Thu May 6 16:02:33 2010 (r46366)
+++ trunk/t/pmc/stringbuilder.t Thu May 6 16:07:46 2010 (r46367)
@@ -20,9 +20,10 @@
.sub 'main' :main
.include 'test_more.pir'
- plan(17)
+ plan(21)
test_create() # 2 tests
test_push_string() # 9 tests
+ test_push_pmc() # 4 tests
test_push_string_unicode() # 1 test
test_i_concatenate() # 1 test
test_set_string_native() # 3 tests
@@ -93,6 +94,26 @@
.end
+.sub 'test_push_pmc'
+ .local pmc sb
+ sb = new ["StringBuilder"]
+
+ box $P0, "foo"
+ push sb, $P0
+ $S0 = sb
+ is( $S0, "foo", "First string pushed")
+
+ box $P0, "bar"
+ push sb, $P0
+ $S1 = sb
+ is( $S1, "foobar", "Second string pushed")
+
+ is( $S0, "foo", "... without clobbering first string")
+
+ $I0 = sb
+ is( $I0, 128, "... and capacity still 128" )
+.end
+
.sub 'test_push_string_unicode'
.local pmc sb
sb = new ["StringBuilder"]
More information about the parrot-commits
mailing list