Project

General

Profile

Feature #6670 ยป 0001-Deprecate-lines-bytes-chars-codepoints-of-IO-likes.patch

knu (Akinori MUSHA), 11/27/2012 11:56 PM

View differences:

ChangeLog
1
Tue Nov 27 23:45:47 2012  Akinori MUSHA  <knu@iDaemons.org>
2

  
3
	* io.c (rb_io_lines, rb_io_bytes, rb_io_chars, rb_io_codepoints):
4
	  Deprecate IO#{lines,bytes,chars,codepoints} and those of ARGF.
5
	  [Feature #6670]
6

  
7
	* ext/stringio/stringio.c (strio_lines, strio_bytes, strio_chars)
8
	  (strio_codepoints): Deprecate
9
	  StringIO#{lines,bytes,chars,codepoints}. [Feature #6670]
10

  
11
	* ext/zlib/zlib.c (rb_gzreader_lines, rb_gzreader_bytes):
12
	  Deprecate Zlib::GzipReader#{lines,bytes}. [Feature #6670]
13

  
1 14
Tue Nov 27 22:03:09 2012  Akinori MUSHA  <knu@iDaemons.org>
2 15

  
3 16
	* string.c (rb_str_enumerate_chars, rb_str_enumerate_codepoints)
NEWS
66 66
    * extended method:
67 67
      * Hash#default_proc= can be passed nil to clear the default proc.
68 68

  
69
  * IO
70
    * deprecated methods:
71
      * IO#lines, #bytes, #chars and #codepoints are deprecated.
72

  
69 73
  * Kernel
70 74
    * added method:
71 75
      * added Kernel#Hash conversion method like Array() or Float().
......
306 310
    * Shellwords#shelljoin() accepts non-string objects in the given
307 311
      array, each of which is stringified using to_s.
308 312

  
313
* stringio
314
  * deprecated methods:
315
    * StringIO#lines, #bytes, #chars and #codepoints are deprecated.
316

  
309 317
* syslog
310 318
  * Added Syslog::Logger which provides a Logger API atop Syslog.
311 319
  * Syslog::Priority, Syslog::Level, Syslog::Option and Syslog::Macros
......
329 337
  * Added support for the new deflate strategies Zlib::RLE and Zlib::FIXED.
330 338
  * Zlib streams are now processed without the GVL.  This allows gzip, zlib and
331 339
    deflate streams to be processed in parallel.
340
  * deprecated methods:
341
    * Zlib::GzipReader#lines and #bytes are deprecated.
332 342

  
333 343
=== Language changes
334 344

  
......
354 364
    works because str.lines returns an array.  Replace lines with
355 365
    each_line in such cases.
356 366

  
367
  * IO#lines
368
  * IO#chars
369
  * IO#codepoints
370
  * IO#bytes
371
  * ARGF#lines
372
  * ARGF#chars
373
  * ARGF#codepoints
374
  * ARGF#bytes
375
  * StringIO#lines
376
  * StringIO#chars
377
  * StringIO#codepoints
378
  * StringIO#bytes
379
  * Zlib::GzipReader#lines
380
  * Zlib::GzipReader#bytes
381

  
382
    These methods are deprecated in favor of each_line, each_byte,
383
    each_char and each_codepoint.
384

  
357 385
  * Signal.trap
358 386

  
359 387
    See above.
ext/stringio/stringio.c
630 630

  
631 631
/*
632 632
 * call-seq:
633
 *   strio.bytes {|byte| block }      -> strio
634
 *   strio.bytes                      -> anEnumerator
635
 *
636 633
 *   strio.each_byte {|byte| block }  -> strio
637 634
 *   strio.each_byte                  -> anEnumerator
638 635
 *
......
653 650
}
654 651

  
655 652
/*
653
 *  This is a deprecated alias for <code>each_byte</code>.
654
 */
655
static VALUE
656
strio_bytes(VALUE self)
657
{
658
    rb_warn("StringIO#bytes is deprecated; use #each_byte instead");
659
    if (!rb_block_given_p())
660
	return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0);
661
    return strio_each_byte(self);
662
}
663

  
664
/*
656 665
 * call-seq:
657 666
 *   strio.getc   -> string or nil
658 667
 *
......
840 849

  
841 850
/*
842 851
 * call-seq:
843
 *   strio.chars {|char| block }      -> strio
844
 *   strio.chars                      -> anEnumerator
845
 *
846 852
 *   strio.each_char {|char| block }  -> strio
847 853
 *   strio.each_char                  -> anEnumerator
848 854
 *
......
862 868
}
863 869

  
864 870
/*
871
 *  This is a deprecated alias for <code>each_char</code>.
872
 */
873
static VALUE
874
strio_chars(VALUE self)
875
{
876
    rb_warn("StringIO#chars is deprecated; use #each_char instead");
877
    if (!rb_block_given_p())
878
	return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0);
879
    return strio_each_char(self);
880
}
881

  
882
/*
865 883
 * call-seq:
866
 *   strio.codepoints {|c| block }      -> strio
867
 *   strio.codepoints                   -> anEnumerator
868
 *
869 884
 *   strio.each_codepoint {|c| block }  -> strio
870 885
 *   strio.each_codepoint               -> anEnumerator
871 886
 *
......
896 911
    return self;
897 912
}
898 913

  
914
/*
915
 *  This is a deprecated alias for <code>each_codepoint</code>.
916
 */
917
static VALUE
918
strio_codepoints(VALUE self)
919
{
920
    rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead");
921
    if (!rb_block_given_p())
922
	return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0);
923
    return strio_each_codepoint(self);
924
}
925

  
899 926
/* Boyer-Moore search: copied from regex.c */
900 927
static void
901 928
bm_init_skip(long *skip, const char *pat, long m)
......
1067 1094
 *   strio.each_line(sep,limit) {|line| block } -> strio
1068 1095
 *   strio.each_line(...)                       -> anEnumerator
1069 1096
 *
1070
 *   strio.lines(sep=$/) {|line| block }        -> strio
1071
 *   strio.lines(limit) {|line| block }         -> strio
1072
 *   strio.lines(sep,limit) {|line| block }     -> strio
1073
 *   strio.lines(...)                           -> anEnumerator
1074
 *
1075 1097
 * See IO#each.
1076 1098
 */
1077 1099
static VALUE
......
1094 1116
}
1095 1117

  
1096 1118
/*
1119
 *  This is a deprecated alias for <code>each_line</code>.
1120
 */
1121
static VALUE
1122
strio_lines(int argc, VALUE *argv, VALUE self)
1123
{
1124
    rb_warn("StringIO#lines is deprecated; use #each_line instead");
1125
    if (!rb_block_given_p())
1126
	return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv);
1127
    return strio_each(argc, argv, self);
1128
}
1129

  
1130
/*
1097 1131
 * call-seq:
1098 1132
 *   strio.readlines(sep=$/)    ->   array
1099 1133
 *   strio.readlines(limit)     ->   array
......
1463 1497

  
1464 1498
    rb_define_method(StringIO, "each", strio_each, -1);
1465 1499
    rb_define_method(StringIO, "each_line", strio_each, -1);
1466
    rb_define_method(StringIO, "lines", strio_each, -1);
1500
    rb_define_method(StringIO, "lines", strio_lines, -1);
1467 1501
    rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
1468
    rb_define_method(StringIO, "bytes", strio_each_byte, 0);
1502
    rb_define_method(StringIO, "bytes", strio_bytes, 0);
1469 1503
    rb_define_method(StringIO, "each_char", strio_each_char, 0);
1470
    rb_define_method(StringIO, "chars", strio_each_char, 0);
1504
    rb_define_method(StringIO, "chars", strio_chars, 0);
1471 1505
    rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
1472
    rb_define_method(StringIO, "codepoints", strio_each_codepoint, 0);
1506
    rb_define_method(StringIO, "codepoints", strio_codepoints, 0);
1473 1507
    rb_define_method(StringIO, "getc", strio_getc, 0);
1474 1508
    rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
1475 1509
    rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
ext/zlib/zlib.c
3880 3880
}
3881 3881

  
3882 3882
/*
3883
 * Document-method: Zlib::GzipReader#bytes
3884
 *
3885
 *  This is a deprecated alias for <code>each_byte</code>.
3886
 */
3887
static VALUE
3888
rb_gzreader_bytes(VALUE obj)
3889
{
3890
    rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3891
    if (!rb_block_given_p())
3892
	return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
3893
    return rb_gzreader_each_byte(obj);
3894
}
3895

  
3896
/*
3883 3897
 * Document-method: Zlib::GzipReader#ungetc
3884 3898
 *
3885 3899
 * See Zlib::GzipReader documentation for a description.
......
4146 4160
}
4147 4161

  
4148 4162
/*
4163
 * Document-method: Zlib::GzipReader#lines
4164
 *
4165
 *  This is a deprecated alias for <code>each_line</code>.
4166
 */
4167
static VALUE
4168
rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
4169
{
4170
    rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
4171
    if (!rb_block_given_p())
4172
	return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
4173
    return rb_gzreader_each_line(argc, argv, obj);
4174
}
4175

  
4176
/*
4149 4177
 * Document-method: Zlib::GzipReader#readlines
4150 4178
 *
4151 4179
 * See Zlib::GzipReader documentation for a description.
......
4420 4448
    rb_define_method(cGzipReader, "readbyte", rb_gzreader_readbyte, 0);
4421 4449
    rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
4422 4450
    rb_define_method(cGzipReader, "each_char", rb_gzreader_each_char, 0);
4423
    rb_define_method(cGzipReader, "bytes", rb_gzreader_each_byte, 0);
4451
    rb_define_method(cGzipReader, "bytes", rb_gzreader_bytes, 0);
4424 4452
    rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
4425 4453
    rb_define_method(cGzipReader, "ungetbyte", rb_gzreader_ungetbyte, 1);
4426 4454
    rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
4427 4455
    rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
4428 4456
    rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
4429 4457
    rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
4430
    rb_define_method(cGzipReader, "lines", rb_gzreader_each, -1);
4458
    rb_define_method(cGzipReader, "lines", rb_gzreader_lines, -1);
4431 4459
    rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
4432 4460

  
4433 4461
    /* The OS code of current host */
io.c
3151 3151
 *     ios.each_line(sep,limit) {|line| block } -> ios
3152 3152
 *     ios.each_line(...)                       -> an_enumerator
3153 3153
 *
3154
 *     ios.lines(sep=$/) {|line| block }        -> ios
3155
 *     ios.lines(limit) {|line| block }         -> ios
3156
 *     ios.lines(sep,limit) {|line| block }     -> ios
3157
 *     ios.lines(...)                           -> an_enumerator
3158
 *
3159 3154
 *  Executes the block for every line in <em>ios</em>, where lines are
3160 3155
 *  separated by <i>sep</i>. <em>ios</em> must be opened for
3161 3156
 *  reading or an <code>IOError</code> will be raised.
......
3190 3185
}
3191 3186

  
3192 3187
/*
3188
 *  This is a deprecated alias for <code>each_line</code>.
3189
 */
3190

  
3191
static VALUE
3192
rb_io_lines(int argc, VALUE *argv, VALUE io)
3193
{
3194
    rb_warn("IO#lines is deprecated; use #each_line instead");
3195
    if (!rb_block_given_p())
3196
	return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv);
3197
    return rb_io_each_line(argc, argv, io);
3198
}
3199

  
3200
/*
3193 3201
 *  call-seq:
3194
 *     ios.bytes {|byte| block }      -> ios
3195
 *     ios.bytes                      -> an_enumerator
3196
 *
3197 3202
 *     ios.each_byte {|byte| block }  -> ios
3198 3203
 *     ios.each_byte                  -> an_enumerator
3199 3204
 *
......
3233 3238
    return io;
3234 3239
}
3235 3240

  
3241
/*
3242
 *  This is a deprecated alias for <code>each_byte</code>.
3243
 */
3244

  
3245
static VALUE
3246
rb_io_bytes(VALUE io)
3247
{
3248
    rb_warn("IO#bytes is deprecated; use #each_byte instead");
3249
    if (!rb_block_given_p())
3250
	return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0);
3251
    return rb_io_each_byte(io);
3252
}
3253

  
3236 3254
static VALUE
3237 3255
io_getc(rb_io_t *fptr, rb_encoding *enc)
3238 3256
{
......
3338 3356

  
3339 3357
/*
3340 3358
 *  call-seq:
3341
 *     ios.chars {|c| block }      -> ios
3342
 *     ios.chars                   -> an_enumerator
3343
 *
3344 3359
 *     ios.each_char {|c| block }  -> ios
3345 3360
 *     ios.each_char               -> an_enumerator
3346 3361
 *
......
3373 3388
    return io;
3374 3389
}
3375 3390

  
3391
/*
3392
 *  This is a deprecated alias for <code>each_char</code>.
3393
 */
3394

  
3395
static VALUE
3396
rb_io_chars(VALUE io)
3397
{
3398
    rb_warn("IO#chars is deprecated; use #each_char instead");
3399
    if (!rb_block_given_p())
3400
	return rb_enumeratorize(io, ID2SYM(rb_intern("each_char")), 0, 0);
3401
    return rb_io_each_char(io);
3402
}
3403

  
3376 3404

  
3377 3405
/*
3378 3406
 *  call-seq:
......
3470 3498
    return io;
3471 3499
}
3472 3500

  
3501
/*
3502
 *  This is a deprecated alias for <code>each_codepoint</code>.
3503
 */
3504

  
3505
static VALUE
3506
rb_io_codepoints(VALUE io)
3507
{
3508
    rb_warn("IO#codepoints is deprecated; use #each_codepoint instead");
3509
    if (!rb_block_given_p())
3510
	return rb_enumeratorize(io, ID2SYM(rb_intern("each_codepoint")), 0, 0);
3511
    return rb_io_each_codepoint(io);
3512
}
3473 3513

  
3474 3514

  
3475 3515
/*
......
10758 10798
 *     ARGF.each_line(sep=$/,limit) {|line| block }  -> ARGF
10759 10799
 *     ARGF.each_line(...)                           -> an_enumerator
10760 10800
 *
10761
 *     ARGF.lines(sep=$/)           {|line| block }   -> ARGF
10762
 *     ARGF.lines(sep=$/,limit)     {|line| block }   -> ARGF
10763
 *     ARGF.lines(...)                                -> an_enumerator
10764
 *
10765 10801
 *  Returns an enumerator which iterates over each line (separated by _sep_,
10766 10802
 *  which defaults to your platform's newline character) of each file in
10767 10803
 *  +ARGV+. If a block is supplied, each line in turn will be yielded to the
......
10796 10832
}
10797 10833

  
10798 10834
/*
10835
 *  This is a deprecated alias for <code>each_line</code>.
10836
 */
10837

  
10838
static VALUE
10839
argf_lines(int argc, VALUE *argv, VALUE argf)
10840
{
10841
    rb_warn("ARGF#lines is deprecated; use #each_line instead");
10842
    if (!rb_block_given_p())
10843
	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_line")), argc, argv);
10844
    return argf_each_line(argc, argv, argf);
10845
}
10846

  
10847
/*
10799 10848
 *  call-seq:
10800 10849
 *     ARGF.bytes     {|byte| block }  -> ARGF
10801 10850
 *     ARGF.bytes                      -> an_enumerator
......
10831 10880
}
10832 10881

  
10833 10882
/*
10883
 *  This is a deprecated alias for <code>each_byte</code>.
10884
 */
10885

  
10886
static VALUE
10887
argf_bytes(VALUE argf)
10888
{
10889
    rb_warn("ARGF#bytes is deprecated; use #each_byte instead");
10890
    if (!rb_block_given_p())
10891
	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_byte")), 0, 0);
10892
    return argf_each_byte(argf);
10893
}
10894

  
10895
/*
10834 10896
 *  call-seq:
10835
 *     ARGF.chars      {|char| block }  -> ARGF
10836
 *     ARGF.chars                       -> an_enumerator
10837
 *
10838 10897
 *     ARGF.each_char  {|char| block }  -> ARGF
10839 10898
 *     ARGF.each_char                   -> an_enumerator
10840 10899
 *
......
10861 10920
}
10862 10921

  
10863 10922
/*
10923
 *  This is a deprecated alias for <code>each_char</code>.
10924
 */
10925

  
10926
static VALUE
10927
argf_chars(VALUE argf)
10928
{
10929
    rb_warn("ARGF#chars is deprecated; use #each_char instead");
10930
    if (!rb_block_given_p())
10931
	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_char")), 0, 0);
10932
    return argf_each_char(argf);
10933
}
10934

  
10935
/*
10864 10936
 *  call-seq:
10865
 *     ARGF.codepoints      {|codepoint| block }  -> ARGF
10866
 *     ARGF.codepoints                       -> an_enumerator
10867
 *
10868 10937
 *     ARGF.each_codepoint  {|codepoint| block }  -> ARGF
10869 10938
 *     ARGF.each_codepoint                   -> an_enumerator
10870 10939
 *
......
10891 10960
}
10892 10961

  
10893 10962
/*
10963
 *  This is a deprecated alias for <code>each_codepoint</code>.
10964
 */
10965

  
10966
static VALUE
10967
argf_codepoints(VALUE argf)
10968
{
10969
    rb_warn("ARGF#codepoints is deprecated; use #each_codepoint instead");
10970
    if (!rb_block_given_p())
10971
	return rb_enumeratorize(argf, ID2SYM(rb_intern("each_codepoint")), 0, 0);
10972
    return argf_each_codepoint(argf);
10973
}
10974

  
10975
/*
10894 10976
 *  call-seq:
10895 10977
 *     ARGF.filename  -> String
10896 10978
 *     ARGF.path      -> String
......
11470 11552
    rb_define_method(rb_cIO, "each_byte",  rb_io_each_byte, 0);
11471 11553
    rb_define_method(rb_cIO, "each_char",  rb_io_each_char, 0);
11472 11554
    rb_define_method(rb_cIO, "each_codepoint",  rb_io_each_codepoint, 0);
11473
    rb_define_method(rb_cIO, "lines",  rb_io_each_line, -1);
11474
    rb_define_method(rb_cIO, "bytes",  rb_io_each_byte, 0);
11475
    rb_define_method(rb_cIO, "chars",  rb_io_each_char, 0);
11476
    rb_define_method(rb_cIO, "codepoints",  rb_io_each_codepoint, 0);
11555
    rb_define_method(rb_cIO, "lines",  rb_io_lines, -1);
11556
    rb_define_method(rb_cIO, "bytes",  rb_io_bytes, 0);
11557
    rb_define_method(rb_cIO, "chars",  rb_io_chars, 0);
11558
    rb_define_method(rb_cIO, "codepoints",  rb_io_codepoints, 0);
11477 11559

  
11478 11560
    rb_define_method(rb_cIO, "syswrite", rb_io_syswrite, 1);
11479 11561
    rb_define_method(rb_cIO, "sysread",  rb_io_sysread, -1);
......
11588 11670
    rb_define_method(rb_cARGF, "each_byte",  argf_each_byte, 0);
11589 11671
    rb_define_method(rb_cARGF, "each_char",  argf_each_char, 0);
11590 11672
    rb_define_method(rb_cARGF, "each_codepoint",  argf_each_codepoint, 0);
11591
    rb_define_method(rb_cARGF, "lines", argf_each_line, -1);
11592
    rb_define_method(rb_cARGF, "bytes", argf_each_byte, 0);
11593
    rb_define_method(rb_cARGF, "chars", argf_each_char, 0);
11594
    rb_define_method(rb_cARGF, "codepoints", argf_each_codepoint, 0);
11673
    rb_define_method(rb_cARGF, "lines", argf_lines, -1);
11674
    rb_define_method(rb_cARGF, "bytes", argf_bytes, 0);
11675
    rb_define_method(rb_cARGF, "chars", argf_chars, 0);
11676
    rb_define_method(rb_cARGF, "codepoints", argf_codepoints, 0);
11595 11677

  
11596 11678
    rb_define_method(rb_cARGF, "read",  argf_read, -1);
11597 11679
    rb_define_method(rb_cARGF, "readpartial",  argf_readpartial, -1);
test/ruby/test_argf.rb
771 771
    assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)
772 772
  end
773 773

  
774
  def test_lines
775
    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
776
      $stderr = $stdout
777
      s = []
778
      ARGF.lines {|l| s << l }
779
      p s
780
    SRC
781
      assert_match(/deprecated/, f.gets)
782
      assert_equal("[\"1\\n\", \"2\\n\", \"3\\n\", \"4\\n\", \"5\\n\", \"6\\n\"]\n", f.read)
783
    end
784
  end
785

  
786
  def test_lines
787
    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
788
      $stderr = $stdout
789
      print Marshal.dump(ARGF.bytes.to_a)
790
    SRC
791
      assert_match(/deprecated/, f.gets)
792
      assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
793
    end
794
  end
795

  
774 796
  def test_bytes
775
    ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
797
    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
798
      $stderr = $stdout
776 799
      print Marshal.dump(ARGF.bytes.to_a)
777 800
    SRC
801
      assert_match(/deprecated/, f.gets)
778 802
      assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
779 803
    end
780 804
  end
781 805

  
782 806
  def test_chars
783
    ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
807
    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
808
      $stderr = $stdout
784 809
      print [Marshal.dump(ARGF.chars.to_a)].pack('m')
785 810
    SRC
811
    assert_match(/deprecated/, f.gets)
786 812
    assert_equal(["1", "\n", "2", "\n", "3", "\n", "4", "\n", "5", "\n", "6", "\n"], Marshal.load(f.read.unpack('m').first))
787 813
    end
788 814
  end
789 815

  
790 816
  def test_codepoints
791
    ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
817
    ruby('-W1', '-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
818
      $stderr = $stdout
792 819
      print Marshal.dump(ARGF.codepoints.to_a)
793 820
    SRC
821
      assert_match(/deprecated/, f.gets)
794 822
      assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read))
795 823
    end
796 824
  end
test/ruby/test_io.rb
260 260
    }
261 261
  end
262 262

  
263
  def test_codepoints
264
    make_tempfile {|t|
265
      bug2959 = '[ruby-core:28650]'
266
      a = ""
267
      File.open(t, 'rt') {|f|
268
        assert_warn(/deprecated/) {
269
          f.codepoints {|c| a << c}
270
        }
271
      }
272
      assert_equal("foo\nbar\nbaz\n", a, bug2959)
273
    }
274
  end
275

  
263 276
  def test_rubydev33072
264 277
    t = make_tempfile
265 278
    path = t.path
......
1303 1316
  end
1304 1317

  
1305 1318
  def test_lines
1319
    verbose, $VERBOSE = $VERBOSE, nil
1306 1320
    pipe(proc do |w|
1307 1321
      w.puts "foo"
1308 1322
      w.puts "bar"
1309 1323
      w.puts "baz"
1310 1324
      w.close
1311 1325
    end, proc do |r|
1312
      e = r.lines
1326
      e = nil
1327
      assert_warn(/deprecated/) {
1328
        e = r.lines
1329
      }
1313 1330
      assert_equal("foo\n", e.next)
1314 1331
      assert_equal("bar\n", e.next)
1315 1332
      assert_equal("baz\n", e.next)
1316 1333
      assert_raise(StopIteration) { e.next }
1317 1334
    end)
1335
  ensure
1336
    $VERBOSE = verbose
1318 1337
  end
1319 1338

  
1320 1339
  def test_bytes
1340
    verbose, $VERBOSE = $VERBOSE, nil
1321 1341
    pipe(proc do |w|
1322 1342
      w.binmode
1323 1343
      w.puts "foo"
......
1325 1345
      w.puts "baz"
1326 1346
      w.close
1327 1347
    end, proc do |r|
1328
      e = r.bytes
1348
      e = nil
1349
      assert_warn(/deprecated/) {
1350
        e = r.bytes
1351
      }
1329 1352
      (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
1330 1353
        assert_equal(c.ord, e.next)
1331 1354
      end
1332 1355
      assert_raise(StopIteration) { e.next }
1333 1356
    end)
1357
  ensure
1358
    $VERBOSE = verbose
1334 1359
  end
1335 1360

  
1336 1361
  def test_chars
1362
    verbose, $VERBOSE = $VERBOSE, nil
1337 1363
    pipe(proc do |w|
1338 1364
      w.puts "foo"
1339 1365
      w.puts "bar"
1340 1366
      w.puts "baz"
1341 1367
      w.close
1342 1368
    end, proc do |r|
1343
      e = r.chars
1369
      e = nil
1370
      assert_warn(/deprecated/) {
1371
        e = r.chars
1372
      }
1344 1373
      (%w(f o o) + ["\n"] + %w(b a r) + ["\n"] + %w(b a z) + ["\n"]).each do |c|
1345 1374
        assert_equal(c, e.next)
1346 1375
      end
1347 1376
      assert_raise(StopIteration) { e.next }
1348 1377
    end)
1378
  ensure
1379
    $VERBOSE = verbose
1349 1380
  end
1350 1381

  
1351 1382
  def test_readbyte
1352
-