[svn:parrot] r46355 - in trunk: src/pmc t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Thu May 6 14:11:54 UTC 2010


Author: bacek
Date: Thu May  6 14:11:54 2010
New Revision: 46355
URL: https://trac.parrot.org/parrot/changeset/46355

Log:
Implement StringBuilder.i_concatenate(_str)

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 14:03:19 2010	(r46354)
+++ trunk/src/pmc/stringbuilder.pmc	Thu May  6 14:11:54 2010	(r46355)
@@ -166,6 +166,27 @@
 
 /*
 
+=item C<VTABLE i_concatenate_str()
+
+=item C<VTABLE i_concatenate()
+
+Append string. Synonym for push_string
+
+=cut
+
+*/
+
+    VTABLE void i_concatenate_str(STRING *s) {
+        SELF.push_string(s);
+    }
+
+    VTABLE void i_concatenate(PMC *p) {
+        SELF.push_string(VTABLE_get_string(INTERP, p));
+    }
+
+
+/*
+
 =item C<VTABLE get_integer()>
 
 Returns current capacity of allocated buffer.

Modified: trunk/t/pmc/stringbuilder.t
==============================================================================
--- trunk/t/pmc/stringbuilder.t	Thu May  6 14:03:19 2010	(r46354)
+++ trunk/t/pmc/stringbuilder.t	Thu May  6 14:11:54 2010	(r46355)
@@ -20,10 +20,11 @@
 .sub 'main' :main
     .include 'test_more.pir'
 
-    plan(13)
+    plan(14)
     test_create()               # 2 tests
     test_push_string()          # 9 tests
     test_push_string_unicode()  # 1 test
+    test_i_concatenate()        # 1 test
 
     # END_OF_TESTS
 .end
@@ -103,6 +104,23 @@
     is( $S0, iso-8859-1:"leo tötsch", "Unicode strings appened")
 .end
 
+.sub 'test_i_concatenate'
+    .local pmc sb
+    sb = new ["StringBuilder"]
+
+    concat sb, "foo"
+
+    $P0 = new ["String"]
+    $P0 = "bar"
+    concat sb, $P0
+
+    sb .= "baz"
+
+    $S0 = sb
+    is( $S0, "foobarbaz", "StringBuilder handles concat properly")
+
+.end
+
 # Local Variables:
 #   mode: pir
 #   fill-column: 100


More information about the parrot-commits mailing list