Project

General

Profile

Bug #7231 ยป patch.diff

Glass_saga (Masaki Matsushita), 12/25/2012 12:01 PM

View differences:

ext/stringio/stringio.c
728 728
    rb_encoding *enc, *enc2;
729 729

  
730 730
    if (NIL_P(c)) return Qnil;
731
    check_modifiable(ptr);
731 732
    if (FIXNUM_P(c)) {
732 733
	int cc = FIX2INT(c);
733 734
	char buf[16];
......
792 793
	cl = RSTRING_LEN(c);
793 794
	if (cl == 0) return Qnil;
794 795
    }
796
    check_modifiable(ptr);
795 797
    rb_str_modify(str);
796 798
    if (cl > pos) {
797 799
	char *s;
test/stringio/test_stringio.rb
504 504
    assert_raise(RuntimeError, bug) {s.reopen("")}
505 505
  end
506 506

  
507
  def test_frozen_string
508
    s = StringIO.new("".freeze)
509
    bug = '[ruby-core:48530]'
510
    assert_raise(IOError, bug) {s.write("foo")}
511
    assert_raise(IOError, bug) {s.ungetc("a")}
512
    assert_raise(IOError, bug) {s.ungetbyte("a")}
513
  end
514

  
507 515
  def test_readlines_limit_0
508 516
    assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.readlines(0) }
509 517
  end