[前][次][番号順一覧][スレッド一覧]

ruby-changes:26512

From: knu <ko1@a...>
Date: Sun, 23 Dec 2012 02:22:17 +0900 (JST)
Subject: [ruby-changes:26512] knu:r38563 (trunk): Deprecate #{lines,bytes,chars,codepoints} of IO-likes.

knu	2012-12-23 02:22:04 +0900 (Sun, 23 Dec 2012)

  New Revision: 38563

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38563

  Log:
    Deprecate #{lines,bytes,chars,codepoints} of IO-likes.
    
    * io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints):
      Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF.
      [Feature #6670]
    
    * ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars)
      (strio_codepoints): Deprecate
      StringIO#{lines,bytes,chars,codepoints}. [Feature #6670]
    
    * ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes):
      Deprecate Zlib::GzipReader#{lines,bytes}. [Feature #6670]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/ext/stringio/stringio.c
    trunk/ext/zlib/zlib.c
    trunk/io.c
    trunk/test/ruby/test_argf.rb
    trunk/test/ruby/test_io.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38562)
+++ ChangeLog	(revision 38563)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 23 01:52:01 2012  Akinori MUSHA  <knu@i...>
+
+	* io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints):
+	  Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF.
+	  [Feature #6670]
+
+	* ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars)
+	  (strio_codepoints): Deprecate
+	  StringIO#{lines,bytes,chars,codepoints}. [Feature #6670]
+
+	* ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes):
+	  Deprecate Zlib::GzipReader#{lines,bytes}. [Feature #6670]
+
 Sat Dec 23 01:35:00 2012  Zachary Scott  <zachary@z...>
 
 	* lib/optparse.rb: Documentation for OptionParser to remove 'shadowed
Index: io.c
===================================================================
--- io.c	(revision 38562)
+++ io.c	(revision 38563)
@@ -3216,11 +3216,6 @@ rb_io_readlines(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/io.c#L3216
  *     ios.each_line(sep,limit) {|line| block } -> ios
  *     ios.each_line(...)                       -> an_enumerator
  *
- *     ios.lines(sep=$/) {|line| block }        -> ios
- *     ios.lines(limit) {|line| block }         -> ios
- *     ios.lines(sep,limit) {|line| block }     -> ios
- *     ios.lines(...)                           -> an_enumerator
- *
  *  Executes the block for every line in <em>ios</em>, where lines are
  *  separated by <i>sep</i>. <em>ios</em> must be opened for
  *  reading or an <code>IOError</code> will be raised.
@@ -3255,10 +3250,20 @@ rb_io_each_line(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/io.c#L3250
 }
 
 /*
+ *  This is a deprecated alias for <code>each_line</code>.
+ */
+
+static VALUE
+rb_io_lines(int argc, VALUE *argv, VALUE io)
+{
+    rb_warn("IO#lines is deprecated; use #each_line instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv);
+    return rb_io_each_line(argc, argv, io);
+}
+
+/*
  *  call-seq:
- *     ios.bytes {|byte| block }      -> ios
- *     ios.bytes                      -> an_enumerator
- *
  *     ios.each_byte {|byte| block }  -> ios
  *     ios.each_byte                  -> an_enumerator
  *
@@ -3298,6 +3303,19 @@ rb_io_each_byte(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L3303
     return io;
 }
 
+/*
+ *  This is a deprecated alias for <code>each_byte</code>.
+ */
+
+static VALUE
+rb_io_bytes(VALUE io)
+{
+    rb_warn("IO#bytes is deprecated; use #each_byte instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0);
+    return rb_io_each_byte(io);
+}
+
 static VALUE
 io_getc(rb_io_t *fptr, rb_encoding *enc)
 {
@@ -3403,9 +3421,6 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/io.c#L3421
 
 /*
  *  call-seq:
- *     ios.chars {|c| block }      -> ios
- *     ios.chars                   -> an_enumerator
- *
  *     ios.each_char {|c| block }  -> ios
  *     ios.each_char               -> an_enumerator
  *
@@ -3438,6 +3453,19 @@ rb_io_each_char(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L3453
     return io;
 }
 
+/*
+ *  This is a deprecated alias for <code>each_char</code>.
+ */
+
+static VALUE
+rb_io_chars(VALUE io)
+{
+    rb_warn("IO#chars is deprecated; use #each_char instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(io, ID2SYM(rb_intern("each_char")), 0, 0);
+    return rb_io_each_char(io);
+}
+
 
 /*
  *  call-seq:
@@ -3535,6 +3563,18 @@ rb_io_each_codepoint(VALUE io) https://github.com/ruby/ruby/blob/trunk/io.c#L3563
     return io;
 }
 
+/*
+ *  This is a deprecated alias for <code>each_codepoint</code>.
+ */
+
+static VALUE
+rb_io_codepoints(VALUE io)
+{
+    rb_warn("IO#codepoints is deprecated; use #each_codepoint instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(io, ID2SYM(rb_intern("each_codepoint")), 0, 0);
+    return rb_io_each_codepoint(io);
+}
 
 
 /*
@@ -10844,10 +10884,6 @@ argf_readbyte(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L10884
  *     ARGF.each_line(sep=$/,limit) {|line| block }  -> ARGF
  *     ARGF.each_line(...)                           -> an_enumerator
  *
- *     ARGF.lines(sep=$/)           {|line| block }   -> ARGF
- *     ARGF.lines(sep=$/,limit)     {|line| block }   -> ARGF
- *     ARGF.lines(...)                                -> an_enumerator
- *
  *  Returns an enumerator which iterates over each line (separated by _sep_,
  *  which defaults to your platform's newline character) of each file in
  *  +ARGV+. If a block is supplied, each line in turn will be yielded to the
@@ -10882,6 +10918,19 @@ argf_each_line(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/io.c#L10918
 }
 
 /*
+ *  This is a deprecated alias for <code>each_line</code>.
+ */
+
+static VALUE
+argf_lines(int argc, VALUE *argv, VALUE argf)
+{
+    rb_warn("ARGF#lines is deprecated; use #each_line instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_line")), argc, argv);
+    return argf_each_line(argc, argv, argf);
+}
+
+/*
  *  call-seq:
  *     ARGF.bytes     {|byte| block }  -> ARGF
  *     ARGF.bytes                      -> an_enumerator
@@ -10917,10 +10966,20 @@ argf_each_byte(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L10966
 }
 
 /*
+ *  This is a deprecated alias for <code>each_byte</code>.
+ */
+
+static VALUE
+argf_bytes(VALUE argf)
+{
+    rb_warn("ARGF#bytes is deprecated; use #each_byte instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_byte")), 0, 0);
+    return argf_each_byte(argf);
+}
+
+/*
  *  call-seq:
- *     ARGF.chars      {|char| block }  -> ARGF
- *     ARGF.chars                       -> an_enumerator
- *
  *     ARGF.each_char  {|char| block }  -> ARGF
  *     ARGF.each_char                   -> an_enumerator
  *
@@ -10947,10 +11006,20 @@ argf_each_char(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L11006
 }
 
 /*
+ *  This is a deprecated alias for <code>each_char</code>.
+ */
+
+static VALUE
+argf_chars(VALUE argf)
+{
+    rb_warn("ARGF#chars is deprecated; use #each_char instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_char")), 0, 0);
+    return argf_each_char(argf);
+}
+
+/*
  *  call-seq:
- *     ARGF.codepoints      {|codepoint| block }  -> ARGF
- *     ARGF.codepoints                       -> an_enumerator
- *
  *     ARGF.each_codepoint  {|codepoint| block }  -> ARGF
  *     ARGF.each_codepoint                   -> an_enumerator
  *
@@ -10977,6 +11046,19 @@ argf_each_codepoint(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L11046
 }
 
 /*
+ *  This is a deprecated alias for <code>each_codepoint</code>.
+ */
+
+static VALUE
+argf_codepoints(VALUE argf)
+{
+    rb_warn("ARGF#codepoints is deprecated; use #each_codepoint instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_codepoint")), 0, 0);
+    return argf_each_codepoint(argf);
+}
+
+/*
  *  call-seq:
  *     ARGF.filename  -> String
  *     ARGF.path      -> String
@@ -11556,10 +11638,10 @@ Init_IO(void) https://github.com/ruby/ruby/blob/trunk/io.c#L11638
     rb_define_method(rb_cIO, "each_byte",  rb_io_each_byte, 0);
     rb_define_method(rb_cIO, "each_char",  rb_io_each_char, 0);
     rb_define_method(rb_cIO, "each_codepoint",  rb_io_each_codepoint, 0);
-    rb_define_method(rb_cIO, "lines",  rb_io_each_line, -1);
-    rb_define_method(rb_cIO, "bytes",  rb_io_each_byte, 0);
-    rb_define_method(rb_cIO, "chars",  rb_io_each_char, 0);
-    rb_define_method(rb_cIO, "codepoints",  rb_io_each_codepoint, 0);
+    rb_define_method(rb_cIO, "lines",  rb_io_lines, -1);
+    rb_define_method(rb_cIO, "bytes",  rb_io_bytes, 0);
+    rb_define_method(rb_cIO, "chars",  rb_io_chars, 0);
+    rb_define_method(rb_cIO, "codepoints",  rb_io_codepoints, 0);
 
     rb_define_method(rb_cIO, "syswrite", rb_io_syswrite, 1);
     rb_define_method(rb_cIO, "sysread",  rb_io_sysread, -1);
@@ -11674,10 +11756,10 @@ Init_IO(void) https://github.com/ruby/ruby/blob/trunk/io.c#L11756
     rb_define_method(rb_cARGF, "each_byte",  argf_each_byte, 0);
     rb_define_method(rb_cARGF, "each_char",  argf_each_char, 0);
     rb_define_method(rb_cARGF, "each_codepoint",  argf_each_codepoint, 0);
-    rb_define_method(rb_cARGF, "lines", argf_each_line, -1);
-    rb_define_method(rb_cARGF, "bytes", argf_each_byte, 0);
-    rb_define_method(rb_cARGF, "chars", argf_each_char, 0);
-    rb_define_method(rb_cARGF, "codepoints", argf_each_codepoint, 0);
+    rb_define_method(rb_cARGF, "lines", argf_lines, -1);
+    rb_define_method(rb_cARGF, "bytes", argf_bytes, 0);
+    rb_define_method(rb_cARGF, "chars", argf_chars, 0);
+    rb_define_method(rb_cARGF, "codepoints", argf_codepoints, 0);
 
     rb_define_method(rb_cARGF, "read",  argf_read, -1);
     rb_define_method(rb_cARGF, "readpartial",  argf_readpartial, -1);
Index: ext/zlib/zlib.c
===================================================================
--- ext/zlib/zlib.c	(revision 38562)
+++ ext/zlib/zlib.c	(revision 38563)
@@ -3880,6 +3880,20 @@ rb_gzreader_each_byte(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L3880
 }
 
 /*
+ * Document-method: Zlib::GzipReader#bytes
+ *
+ *  This is a deprecated alias for <code>each_byte</code>.
+ */
+static VALUE
+rb_gzreader_bytes(VALUE obj)
+{
+    rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
+    return rb_gzreader_each_byte(obj);
+}
+
+/*
  * Document-method: Zlib::GzipReader#ungetc
  *
  * See Zlib::GzipReader documentation for a description.
@@ -4146,6 +4160,20 @@ rb_gzreader_each(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L4160
 }
 
 /*
+ * Document-method: Zlib::GzipReader#lines
+ *
+ *  This is a deprecated alias for <code>each_line</code>.
+ */
+static VALUE
+rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
+{
+    rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
+    return rb_gzreader_each_line(argc, argv, obj);
+}
+
+/*
  * Document-method: Zlib::GzipReader#readlines
  *
  * See Zlib::GzipReader documentation for a description.
@@ -4420,14 +4448,14 @@ Init_zlib() https://github.com/ruby/ruby/blob/trunk/ext/zlib/zlib.c#L4448
     rb_define_method(cGzipReader, "readbyte", rb_gzreader_readbyte, 0);
     rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
     rb_define_method(cGzipReader, "each_char", rb_gzreader_each_char, 0);
-    rb_define_method(cGzipReader, "bytes", rb_gzreader_each_byte, 0);
+    rb_define_method(cGzipReader, "bytes", rb_gzreader_bytes, 0);
     rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
     rb_define_method(cGzipReader, "ungetbyte", rb_gzreader_ungetbyte, 1);
     rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
     rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
     rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
     rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
-    rb_define_method(cGzipReader, "lines", rb_gzreader_each, -1);
+    rb_define_method(cGzipReader, "lines", rb_gzreader_lines, -1);
     rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
 
     /* The OS code of current host */
Index: ext/stringio/stringio.c
===================================================================
--- ext/stringio/stringio.c	(revision 38562)
+++ ext/stringio/stringio.c	(revision 38563)
@@ -630,9 +630,6 @@ strio_get_sync(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L630
 
 /*
  * call-seq:
- *   strio.bytes {|byte| block }      -> strio
- *   strio.bytes                      -> anEnumerator
- *
  *   strio.each_byte {|byte| block }  -> strio
  *   strio.each_byte                  -> anEnumerator
  *
@@ -653,6 +650,18 @@ strio_each_byte(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L650
 }
 
 /*
+ *  This is a deprecated alias for <code>each_byte</code>.
+ */
+static VALUE
+strio_bytes(VALUE self)
+{
+    rb_warn("StringIO#bytes is deprecated; use #each_byte instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0);
+    return strio_each_byte(self);
+}
+
+/*
  * call-seq:
  *   strio.getc   -> string or nil
  *
@@ -840,9 +849,6 @@ strio_readbyte(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L849
 
 /*
  * call-seq:
- *   strio.chars {|char| block }      -> strio
- *   strio.chars                      -> anEnumerator
- *
  *   strio.each_char {|char| block }  -> strio
  *   strio.each_char                  -> anEnumerator
  *
@@ -862,10 +868,19 @@ strio_each_char(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L868
 }
 
 /*
+ *  This is a deprecated alias for <code>each_char</code>.
+ */
+static VALUE
+strio_chars(VALUE self)
+{
+    rb_warn("StringIO#chars is deprecated; use #each_char instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0);
+    return strio_each_char(self);
+}
+
+/*
  * call-seq:
- *   strio.codepoints {|c| block }      -> strio
- *   strio.codepoints                   -> anEnumerator
- *
  *   strio.each_codepoint {|c| block }  -> strio
  *   strio.each_codepoint               -> anEnumerator
  *
@@ -896,6 +911,18 @@ strio_each_codepoint(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L911
     return self;
 }
 
+/*
+ *  This is a deprecated alias for <code>each_codepoint</code>.
+ */
+static VALUE
+strio_codepoints(VALUE self)
+{
+    rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0);
+    return strio_each_codepoint(self);
+}
+
 /* Boyer-Moore search: copied from regex.c */
 static void
 bm_init_skip(long *skip, const char *pat, long m)
@@ -1067,11 +1094,6 @@ strio_readline(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L1094
  *   strio.each_line(sep,limit) {|line| block } -> strio
  *   strio.each_line(...)                       -> anEnumerator
  *
- *   strio.lines(sep=$/) {|line| block }        -> strio
- *   strio.lines(limit) {|line| block }         -> strio
- *   strio.lines(sep,limit) {|line| block }     -> strio
- *   strio.lines(...)                           -> anEnumerator
- *
  * See IO#each.
  */
 static VALUE
@@ -1094,6 +1116,18 @@ strio_each(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L1116
 }
 
 /*
+ *  This is a deprecated alias for <code>each_line</code>.
+ */
+static VALUE
+strio_lines(int argc, VALUE *argv, VALUE self)
+{
+    rb_warn("StringIO#lines is deprecated; use #each_line instead");
+    if (!rb_block_given_p())
+	return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv);
+    return strio_each(argc, argv, self);
+}
+
+/*
  * call-seq:
  *   strio.readlines(sep=$/)    ->   array
  *   strio.readlines(limit)     ->   array
@@ -1463,13 +1497,13 @@ Init_stringio() https://github.com/ruby/ruby/blob/trunk/ext/stringio/stringio.c#L1497
 
     rb_define_method(StringIO, "each", strio_each, -1);
     rb_define_method(StringIO, "each_line", strio_each, -1);
-    rb_define_method(StringIO, "lines", strio_each, -1);
+    rb_define_method(StringIO, "lines", strio_lines, -1);
     rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
-    rb_define_method(StringIO, "bytes", strio_each_byte, 0);
+    rb_define_method(StringIO, "bytes", strio_bytes, 0);
     rb_define_method(StringIO, "each_char", strio_each_char, 0);
-    rb_define_method(StringIO, "chars", strio_each_char, 0);
+    rb_define_method(StringIO, "chars", strio_chars, 0);
     rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
-    rb_define_method(StringIO, "codepoints", strio_each_codepoint, 0);
+    rb_define_method(StringIO, "codepoints", strio_codepoints, 0);
     rb_define_method(StringIO, "getc", strio_getc, 0);
     rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
     rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
Index: NEWS
===================================================================
--- NEWS	(revision 38562)
+++ NEWS	(revision 38563)
@@ -67,6 +67,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L67
     * extended method:
       * Hash#default_proc= can be passed nil to clear the default proc.
 
+  * IO
+    * deprecated methods:
+      * IO#lines, #bytes, #chars and #codepoints are deprecated.
+
   * Kernel
     * added method:
       * added Kernel#Hash conversion method like Array() or Float().
@@ -335,6 +339,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L339
     * Shellwords#shelljoin() accepts non-string objects in the given
       array, each of which is stringified using to_s.
 
+* stringio
+  * deprecated methods:
+    * StringIO#lines, #bytes, #chars and #codepoints are deprecated.
+
 * syslog
   * Added Syslog::Logger which provides a Logger API atop Syslog.
   * Syslog::Priority, Syslog::Level, Syslog::Option and Syslog::Macros
@@ -358,6 +366,8 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L366
   * Added support for the new deflate strategies Zlib::RLE and Zlib::FIXED.
   * Zlib streams are now processed without the GVL.  This allows gzip, zlib and
     deflate streams to be processed in parallel.
+  * deprecated methods:
+    * Zlib::GzipReader#lines and #bytes are deprecated.
 
 === Language changes
 
@@ -383,6 +393,24 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L393
     works because str.lines returns an array.  Replace lines with
     each_line in such cases.
 
+  * IO#lines
+  * IO#chars
+  * IO#codepoints
+  * IO#bytes
+  * ARGF#lines
+  * ARGF#chars
+  * ARGF#codepoints
+  * ARGF#bytes
+  * StringIO#lines
+  * StringIO#chars
+  * StringIO#codepoints
+  * StringIO#bytes
+  * Zlib::GzipReader#lines
+  * Zlib::GzipReader#bytes
+
+    These methods are deprecated in favor of each_line, each_byte,
+    each_char and each_codepoint.
+
   * Signal.trap
 
     See above.
Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 38562)
+++ test/ruby/test_argf.rb	(revision 38563)
@@ -771,26 +771,54 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_argf.rb#L771
     assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)
   end
 
+  def test_lines
+    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+      $stderr = $stdout
+      s = []
+      ARGF.lines {|l| s << l }
+      p s
+    SRC
+      assert_match(/deprecated/, f.gets)
+      assert_equal("[\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\"]\n", f.read)
+    end
+  end
+
+  def test_lines
+    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+      $stderr = $stdout
+      print Marshal.dump(ARGF.bytes.to_a)
+    SRC
+      assert_match(/deprecated/, f.gets)
+      assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
+    end
+  end
+
   def test_bytes
-    ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
+      $s (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]