Skip to content
Permalink
Browse files

Merge pull request #597 from kachick/implement-string-concat

Implement String#concat
  • Loading branch information
alex committed Apr 10, 2013
2 parents 2097973 + 271e09c commit 946205f025f9b7deccde74eaaee39afc1300d32f
Showing with 3 additions and 3 deletions.
  1. +0 −3 spec/tags/core/string/concat_tags.txt
  2. +2 −0 tests/objects/test_stringobject.py
  3. +1 −0 topaz/objects/stringobject.py
@@ -1,15 +1,12 @@
fails:String#concat concatenates the given argument to self and returns self
fails:String#concat converts the given argument to a String using to_str
fails:String#concat raises a TypeError if the given argument can't be converted to a String
fails:String#concat raises a RuntimeError when self is frozen
fails:String#concat taints self if other is tainted
fails:String#concat untrusts self if other is untrusted
fails:String#concat with Integer concatencates the argument interpreted as a codepoint
fails:String#concat with Integer returns a ASCII-8BIT string if self is US-ASCII and the argument is between 128-255 (inclusive)
fails:String#concat with Integer raises RangeError if the argument is an invalid codepoint for self's encoding
fails:String#concat with Integer raises RangeError if the argument is negative
fails:String#concat with Integer doesn't call to_int on its argument
fails:String#concat with Integer raises a RuntimeError when self is frozen
fails:String#concat when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses self's encoding if both are empty
fails:String#concat when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses self's encoding if the argument is empty
fails:String#concat when self is in an ASCII-incompatible encoding incompatible with the argument's encoding uses the argument's encoding if self is empty
@@ -13,6 +13,8 @@ def test_new(self, space):
def test_lshift(self, space):
w_res = space.execute('return "abc" << "def" << "ghi"')
assert space.str_w(w_res) == "abcdefghi"
w_res = space.execute('return "abc".concat("def").concat("ghi")')
assert space.str_w(w_res) == "abcdefghi"

def test_plus(self, space):
w_res = space.execute('return "abc" + "def" + "ghi"')
@@ -446,6 +446,7 @@ def method_times(self, space, times):
return self.strategy.mul(space, self.str_storage, times)

@classdef.method("<<")
@classdef.method("concat")
@check_frozen()
def method_lshift(self, space, w_other):
assert isinstance(w_other, W_StringObject)

0 comments on commit 946205f

Please sign in to comment.
You can’t perform that action at this time.