summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-27 01:26:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-27 01:26:17 +0000
commit9387ff7315b498a6e7c8ab2a4b1582fd6c717524 (patch)
tree0431117437708b8bd35ae46d86b0a6146de870fd /test
parent0783f55cf8b361ede75d7c7b86d82fe1fbbff107 (diff)
multiple arguments
* array.c (rb_ary_concat_multi): take multiple arguments. based on the patch by Satoru Horie. [Feature #12333] * string.c (rb_str_concat_multi, rb_str_prepend_multi): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb6
-rw-r--r--test/ruby/test_string.rb7
2 files changed, 12 insertions, 1 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 54bdd4cee3..addce0d9ba 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -556,7 +556,9 @@ class TestArray < Test::Unit::TestCase
def test_concat
assert_equal(@cls[1, 2, 3, 4], @cls[1, 2].concat(@cls[3, 4]))
assert_equal(@cls[1, 2, 3, 4], @cls[].concat(@cls[1, 2, 3, 4]))
+ assert_equal(@cls[1, 2, 3, 4], @cls[1].concat(@cls[2, 3], [4]))
assert_equal(@cls[1, 2, 3, 4], @cls[1, 2, 3, 4].concat(@cls[]))
+ assert_equal(@cls[1, 2, 3, 4], @cls[1, 2, 3, 4].concat())
assert_equal(@cls[], @cls[].concat(@cls[]))
assert_equal(@cls[@cls[1, 2], @cls[3, 4]], @cls[@cls[1, 2]].concat(@cls[@cls[3, 4]]))
@@ -564,6 +566,10 @@ class TestArray < Test::Unit::TestCase
a.concat(a)
assert_equal([1, 2, 3, 1, 2, 3], a)
+ b = @cls[4, 5]
+ b.concat(b, b)
+ assert_equal([4, 5, 4, 5, 4, 5], b)
+
assert_raise(TypeError) { [0].concat(:foo) }
assert_raise(RuntimeError) { [0].freeze.concat(:foo) }
end
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 4970af15e4..b1d795e183 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -495,6 +495,8 @@ CODE
def test_concat
assert_equal(S("world!"), S("world").concat(33))
assert_equal(S("world!"), S("world").concat(S('!')))
+ b = S("sn")
+ assert_equal(S("snsnsn"), b.concat(b, b))
bug7090 = '[ruby-core:47751]'
result = S("").force_encoding(Encoding::UTF_16LE)
@@ -502,6 +504,7 @@ CODE
expected = S("\u0300".encode(Encoding::UTF_16LE))
assert_equal(expected, result, bug7090)
assert_raise(TypeError) { 'foo' << :foo }
+ assert_raise(RuntimeError) { 'foo'.freeze.concat('bar') }
end
def test_count
@@ -2313,7 +2316,9 @@ CODE
end
def test_prepend
- assert_equal(S("hello world!"), "world!".prepend("hello "))
+ assert_equal(S("hello world!"), "!".prepend("hello ", "world"))
+ b = S("ue")
+ assert_equal(S("ueueue"), b.prepend(b, b))
foo = Object.new
def foo.to_str