* array.c (array_join): copy the encoding of the first element as

an initial encoding.

* array.c (array_join_0): ditto.

* array.c (array_join_1): ditto.

* array.c (inspect_ary): ditto.

* array.c (array_join_1): add an argument to check the appending is
  first one or not.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2011-02-15 07:08:24 +00:00
parent 7798b9667e
commit c7d3b3f1b4
3 changed files with 37 additions and 4 deletions

View file

@ -914,6 +914,13 @@ class TestArray < Test::Unit::TestCase
s = a.join
assert_equal(true, s.tainted?)
assert_equal(true, s.untrusted?)
e = ''.force_encoding('EUC-JP')
u = ''.force_encoding('UTF-8')
assert_equal(Encoding::US_ASCII, [[]].join.encoding)
assert_equal(Encoding::US_ASCII, [1, [u]].join.encoding)
assert_equal(Encoding::UTF_8, [u, [e]].join.encoding)
assert_equal(Encoding::UTF_8, [u, [1]].join.encoding)
ensure
$, = nil
end