ruby-changes:15031
From: matz <ko1@a...>
Date: Sat, 13 Mar 2010 14:56:05 +0900 (JST)
Subject: [ruby-changes:15031] Ruby:r26906 (trunk): * enum.c (enum_join): remove Enumerable#join.
matz 2010-03-13 14:55:46 +0900 (Sat, 13 Mar 2010) New Revision: 26906 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26906 Log: * enum.c (enum_join): remove Enumerable#join. [ruby-core:24786] * array.c (ary_join_1): use #to_ary to detect recursive array. Modified files: trunk/ChangeLog trunk/array.c trunk/enum.c trunk/test/ruby/test_array.rb trunk/test/ruby/test_enum.rb Index: array.c =================================================================== --- array.c (revision 26905) +++ array.c (revision 26906) @@ -1604,7 +1604,7 @@ val = tmp; goto str_join; } - tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_a"); + tmp = rb_check_convert_type(val, T_ARRAY, "Array", "to_ary"); if (!NIL_P(tmp)) { obj = val; val = tmp; Index: ChangeLog =================================================================== --- ChangeLog (revision 26905) +++ ChangeLog (revision 26906) @@ -1,3 +1,9 @@ +Sat Mar 13 14:49:55 2010 Yukihiro Matsumoto <matz@r...> + + * enum.c (enum_join): remove Enumerable#join. [ruby-core:24786] + + * array.c (ary_join_1): use #to_ary to detect recursive array. + Sat Mar 13 12:26:13 2010 Nobuyoshi Nakada <nobu@r...> * include/ruby/io.h (MakeOpenFile): finalize fptr get rid of Index: enum.c =================================================================== --- enum.c (revision 26905) +++ enum.c (revision 26906) @@ -2523,25 +2523,6 @@ } /* - * call-seq: - * enum.join(sep=$,) -> str - * - * Returns a string created by converting each element of the - * <i>enum</i> to a string, separated by <i>sep</i>. - */ - -static VALUE -enum_join(int argc, VALUE *argv, VALUE obj) -{ - VALUE sep; - - rb_scan_args(argc, argv, "01", &sep); - if (NIL_P(sep)) sep = rb_output_fs; - - return rb_ary_join(enum_to_a(0, 0, obj), sep); -} - -/* * The <code>Enumerable</code> mixin provides collection classes with * several traversal and searching methods, and with the ability to * sort. The class must provide a method <code>each</code>, which @@ -2606,7 +2587,6 @@ rb_define_method(rb_mEnumerable, "drop", enum_drop, 1); rb_define_method(rb_mEnumerable, "drop_while", enum_drop_while, 0); rb_define_method(rb_mEnumerable, "cycle", enum_cycle, -1); - rb_define_method(rb_mEnumerable, "join", enum_join, -1); rb_define_method(rb_mEnumerable, "chunk", enum_chunk, -1); rb_define_method(rb_mEnumerable, "slice_before", enum_slice_before, -1); Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 26905) +++ test/ruby/test_array.rb (revision 26906) @@ -1565,7 +1565,7 @@ a << a assert_raise(ArgumentError){a.join} - def (a = Object.new).to_a + def (a = Object.new).to_ary [self] end assert_raise(ArgumentError, '[ruby-core:24150]'){[a].join} Index: test/ruby/test_enum.rb =================================================================== --- test/ruby/test_enum.rb (revision 26905) +++ test/ruby/test_enum.rb (revision 26906) @@ -311,38 +311,6 @@ assert_equal([2,1,3,2,1], @obj.reverse_each.to_a) end - def test_join - ofs = $, - assert_equal("abc", ("a".."c").join("")) - assert_equal("a-b-c", ("a".."c").join("-")) - $, = "-" - assert_equal("a-b-c", ("a".."c").join()) - $, = nil - assert_equal("abc", ("a".."c").join()) - assert_equal("123", (1..3).join()) - assert_raise(TypeError, '[ruby-core:24172]') {("a".."c").join(1)} - class << (e = Object.new.extend(Enumerable)) - def each - yield self - end - end - assert_raise(ArgumentError){e.join("")} - assert_raise(ArgumentError){[e].join("")} - e = Class.new { - include Enumerable - def initialize(*args) - @e = args - end - def each - @e.each {|e| yield e} - end - } - e = e.new(1, e.new(2, e.new(3, e.new(4, 5)))) - assert_equal("1:2:3:4:5", e.join(':'), '[ruby-core:24196]') - ensure - $, = ofs - end - def test_chunk e = [].chunk {|elt| true } assert_equal([], e.to_a) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/