* array.c (recursive_join): raise ArgumentError for joining

recursive array.

* array.c (ary_join_1): ditto.

* test/ruby/test_array.rb (TestArray#test_join2): test updated for
  recursive join.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2009-07-17 02:04:37 +00:00
Родитель 4d70a43e3d
Коммит ae487eda6e
3 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Fri Jul 17 01:22:57 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (recursive_join): raise ArgumentError for joining
recursive array.
* array.c (ary_join_1): ditto.
* test/ruby/test_array.rb (TestArray#test_join2): test updated for
recursive join.
Thu Jul 16 23:32:16 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/extconf.rb,ext/tk/config_list.in: ignore paths which includes

Просмотреть файл

@ -1530,7 +1530,7 @@ recursive_join(VALUE obj, VALUE argp, int recur)
VALUE result = arg[2];
if (recur) {
rb_str_buf_cat_ascii(result, "[...]");
rb_raise(rb_eArgError, "recursive array join");
}
else {
ary_join_1(obj, ary, sep, 0, result);
@ -1573,8 +1573,7 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result)
obj = val;
ary_join:
if (val == ary) {
val = rb_usascii_str_new2("[...]");
goto str_join;
rb_raise(rb_eArgError, "recursive array join");
}
else {
VALUE args[3];

Просмотреть файл

@ -1490,12 +1490,12 @@ class TestArray < Test::Unit::TestCase
def test_join2
a = []
a << a
assert_equal("[...]", a.join)
assert_raise(ArgumentError){a.join}
def (a = Object.new).to_a
[self]
end
assert_equal("[...]", [a].join, '[ruby-core:24150]')
assert_raise(ArgumentError, '[ruby-core:24150]'){[a].join}
assert_equal("12345", [1,[2,[3,4],5]].join)
end