mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Add FrozenError as a subclass of RuntimeError
FrozenError will be used instead of RuntimeError for exceptions raised when there is an attempt to modify a frozen object. The reason for this change is to differentiate exceptions related to frozen objects from generic exceptions such as those generated by Kernel#raise without an exception class. From: Jeremy Evans <code@jeremyevans.net> Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									0b31ce0047
								
							
						
					
					
						commit
						b57915eddc
					
				
					 29 changed files with 97 additions and 89 deletions
				
			
		
							
								
								
									
										19
									
								
								error.c
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								error.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -804,6 +804,7 @@ VALUE rb_eSignal;
 | 
			
		|||
VALUE rb_eFatal;
 | 
			
		||||
VALUE rb_eStandardError;
 | 
			
		||||
VALUE rb_eRuntimeError;
 | 
			
		||||
VALUE rb_eFrozenError;
 | 
			
		||||
VALUE rb_eTypeError;
 | 
			
		||||
VALUE rb_eArgError;
 | 
			
		||||
VALUE rb_eIndexError;
 | 
			
		||||
| 
						 | 
				
			
			@ -2011,16 +2012,21 @@ syserr_eqq(VALUE self, VALUE exc)
 | 
			
		|||
 */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  Document-class: RuntimeError
 | 
			
		||||
 *  Document-class: FrozenError
 | 
			
		||||
 *
 | 
			
		||||
 *  A generic error class raised when an invalid operation is attempted.
 | 
			
		||||
 *  Raised when there is an attempt to modify a frozen object.
 | 
			
		||||
 *
 | 
			
		||||
 *     [1, 2, 3].freeze << 4
 | 
			
		||||
 *
 | 
			
		||||
 *  <em>raises the exception:</em>
 | 
			
		||||
 *
 | 
			
		||||
 *     RuntimeError: can't modify frozen Array
 | 
			
		||||
 *     FrozenError: can't modify frozen Array
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 *  Document-class: RuntimeError
 | 
			
		||||
 *
 | 
			
		||||
 *  A generic error class raised when an invalid operation is attempted.
 | 
			
		||||
 *  Kernel#raise will raise a RuntimeError if no Exception class is
 | 
			
		||||
 *  specified.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -2233,6 +2239,7 @@ Init_Exception(void)
 | 
			
		|||
    rb_define_method(rb_eNoMethodError, "private_call?", nometh_err_private_call_p, 0);
 | 
			
		||||
 | 
			
		||||
    rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
 | 
			
		||||
    rb_eFrozenError = rb_define_class("FrozenError", rb_eRuntimeError);
 | 
			
		||||
    rb_eSecurityError = rb_define_class("SecurityError", rb_eException);
 | 
			
		||||
    rb_eNoMemError = rb_define_class("NoMemoryError", rb_eException);
 | 
			
		||||
    rb_eEncodingError = rb_define_class("EncodingError", rb_eStandardError);
 | 
			
		||||
| 
						 | 
				
			
			@ -2588,7 +2595,7 @@ rb_load_fail(VALUE path, const char *err)
 | 
			
		|||
void
 | 
			
		||||
rb_error_frozen(const char *what)
 | 
			
		||||
{
 | 
			
		||||
    rb_raise(rb_eRuntimeError, "can't modify frozen %s", what);
 | 
			
		||||
    rb_raise(rb_eFrozenError, "can't modify frozen %s", what);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
| 
						 | 
				
			
			@ -2601,11 +2608,11 @@ rb_error_frozen_object(VALUE frozen_obj)
 | 
			
		|||
	VALUE path = rb_ary_entry(debug_info, 0);
 | 
			
		||||
	VALUE line = rb_ary_entry(debug_info, 1);
 | 
			
		||||
 | 
			
		||||
	rb_raise(rb_eRuntimeError, "can't modify frozen %"PRIsVALUE", created at %"PRIsVALUE":%"PRIsVALUE,
 | 
			
		||||
	rb_raise(rb_eFrozenError, "can't modify frozen %"PRIsVALUE", created at %"PRIsVALUE":%"PRIsVALUE,
 | 
			
		||||
		 CLASS_OF(frozen_obj), path, line);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
	rb_raise(rb_eRuntimeError, "can't modify frozen %"PRIsVALUE,
 | 
			
		||||
	rb_raise(rb_eFrozenError, "can't modify frozen %"PRIsVALUE,
 | 
			
		||||
		 CLASS_OF(frozen_obj));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1946,6 +1946,7 @@ RUBY_EXTERN VALUE rb_eKeyError;
 | 
			
		|||
RUBY_EXTERN VALUE rb_eRangeError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eIOError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eRuntimeError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eFrozenError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eSecurityError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eSystemCallError;
 | 
			
		||||
RUBY_EXTERN VALUE rb_eThreadError;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								object.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								object.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1315,7 +1315,7 @@ rb_obj_infect(VALUE victim, VALUE carrier)
 | 
			
		|||
 *
 | 
			
		||||
 *  <em>produces:</em>
 | 
			
		||||
 *
 | 
			
		||||
 *     prog.rb:3:in `<<': can't modify frozen Array (RuntimeError)
 | 
			
		||||
 *     prog.rb:3:in `<<': can't modify frozen Array (FrozenError)
 | 
			
		||||
 *     	from prog.rb:3
 | 
			
		||||
 *
 | 
			
		||||
 *  Objects of the following classes are always frozen: Integer,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,8 +7,8 @@ class Test_StrEncAssociate < Test::Unit::TestCase
 | 
			
		|||
    s = Bug::String.new("abc")
 | 
			
		||||
    s.force_encoding(Encoding::US_ASCII)
 | 
			
		||||
    s.freeze
 | 
			
		||||
    assert_raise(RuntimeError) {s.associate_encoding!(Encoding::US_ASCII)}
 | 
			
		||||
    assert_raise(RuntimeError) {s.associate_encoding!(Encoding::UTF_8)}
 | 
			
		||||
    assert_raise(FrozenError) {s.associate_encoding!(Encoding::US_ASCII)}
 | 
			
		||||
    assert_raise(FrozenError) {s.associate_encoding!(Encoding::UTF_8)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  Encoding.list.select(&:dummy?).each do |enc|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,13 +30,13 @@ class TestDateMarshal < Test::Unit::TestCase
 | 
			
		|||
    a = d.marshal_dump
 | 
			
		||||
    d.freeze
 | 
			
		||||
    assert(d.frozen?)
 | 
			
		||||
    assert_raise(RuntimeError){d.marshal_load(a)}
 | 
			
		||||
    assert_raise(FrozenError){d.marshal_load(a)}
 | 
			
		||||
 | 
			
		||||
    d = DateTime.now
 | 
			
		||||
    a = d.marshal_dump
 | 
			
		||||
    d.freeze
 | 
			
		||||
    assert(d.frozen?)
 | 
			
		||||
    assert_raise(RuntimeError){d.marshal_load(a)}
 | 
			
		||||
    assert_raise(FrozenError){d.marshal_load(a)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -625,7 +625,7 @@ if defined? DBM
 | 
			
		|||
    def test_freeze
 | 
			
		||||
      DBM.open("#{@tmproot}/a") {|d|
 | 
			
		||||
        d.freeze
 | 
			
		||||
        assert_raise(RuntimeError) { d["k"] = "v" }
 | 
			
		||||
        assert_raise(FrozenError) { d["k"] = "v" }
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -722,7 +722,7 @@ if defined? GDBM
 | 
			
		|||
    def test_freeze
 | 
			
		||||
      GDBM.open("#{@tmproot}/a.dbm") {|d|
 | 
			
		||||
        d.freeze
 | 
			
		||||
        assert_raise(RuntimeError) { d["k"] = "v" }
 | 
			
		||||
        assert_raise(FrozenError) { d["k"] = "v" }
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -635,7 +635,7 @@ class TestPathname < Test::Unit::TestCase
 | 
			
		|||
    obj = Pathname.new("a")
 | 
			
		||||
    obj.freeze
 | 
			
		||||
    assert_equal(false, obj.tainted?)
 | 
			
		||||
    assert_raise(RuntimeError) { obj.taint }
 | 
			
		||||
    assert_raise(FrozenError) { obj.taint }
 | 
			
		||||
 | 
			
		||||
    obj = Pathname.new("a")
 | 
			
		||||
    obj.taint
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -601,7 +601,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    assert_equal([4, 5, 4, 5, 4, 5], b)
 | 
			
		||||
 | 
			
		||||
    assert_raise(TypeError) { [0].concat(:foo) }
 | 
			
		||||
    assert_raise(RuntimeError) { [0].freeze.concat(:foo) }
 | 
			
		||||
    assert_raise(FrozenError) { [0].freeze.concat(:foo) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_count
 | 
			
		||||
| 
						 | 
				
			
			@ -1299,10 +1299,10 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
    fa = a.dup.freeze
 | 
			
		||||
    assert_nothing_raised(RuntimeError) { a.replace(a) }
 | 
			
		||||
    assert_raise(RuntimeError) { fa.replace(fa) }
 | 
			
		||||
    assert_raise(FrozenError) { fa.replace(fa) }
 | 
			
		||||
    assert_raise(ArgumentError) { fa.replace() }
 | 
			
		||||
    assert_raise(TypeError) { a.replace(42) }
 | 
			
		||||
    assert_raise(RuntimeError) { fa.replace(42) }
 | 
			
		||||
    assert_raise(FrozenError) { fa.replace(42) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_reverse
 | 
			
		||||
| 
						 | 
				
			
			@ -1530,7 +1530,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    o2 = o1.clone
 | 
			
		||||
    ary << o1 << o2
 | 
			
		||||
    orig = ary.dup
 | 
			
		||||
    assert_raise(RuntimeError, "frozen during comparison") {ary.sort!}
 | 
			
		||||
    assert_raise(FrozenError, "frozen during comparison") {ary.sort!}
 | 
			
		||||
    assert_equal(orig, ary, "must not be modified once frozen")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1762,7 +1762,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    f = a.dup.freeze
 | 
			
		||||
    assert_raise(ArgumentError) { a.uniq!(1) }
 | 
			
		||||
    assert_raise(ArgumentError) { f.uniq!(1) }
 | 
			
		||||
    assert_raise(RuntimeError) { f.uniq! }
 | 
			
		||||
    assert_raise(FrozenError) { f.uniq! }
 | 
			
		||||
 | 
			
		||||
    assert_nothing_raised do
 | 
			
		||||
      a = [ {c: "b"}, {c: "r"}, {c: "w"}, {c: "g"}, {c: "g"} ]
 | 
			
		||||
| 
						 | 
				
			
			@ -1808,7 +1808,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
  def test_uniq_bang_with_freeze
 | 
			
		||||
    ary = [1,2]
 | 
			
		||||
    orig = ary.dup
 | 
			
		||||
    assert_raise(RuntimeError, "frozen during comparison") {
 | 
			
		||||
    assert_raise(FrozenError, "frozen during comparison") {
 | 
			
		||||
      ary.uniq! {|v| ary.freeze; 1}
 | 
			
		||||
    }
 | 
			
		||||
    assert_equal(orig, ary, "must not be modified once frozen")
 | 
			
		||||
| 
						 | 
				
			
			@ -2121,7 +2121,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    assert_raise(ArgumentError) { [0][0, 0, 0] = 0 }
 | 
			
		||||
    assert_raise(ArgumentError) { [0].freeze[0, 0, 0] = 0 }
 | 
			
		||||
    assert_raise(TypeError) { [0][:foo] = 0 }
 | 
			
		||||
    assert_raise(RuntimeError) { [0].freeze[:foo] = 0 }
 | 
			
		||||
    assert_raise(FrozenError) { [0].freeze[:foo] = 0 }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_first2
 | 
			
		||||
| 
						 | 
				
			
			@ -2146,8 +2146,8 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_unshift_error
 | 
			
		||||
    assert_raise(RuntimeError) { [].freeze.unshift('cat') }
 | 
			
		||||
    assert_raise(RuntimeError) { [].freeze.unshift() }
 | 
			
		||||
    assert_raise(FrozenError) { [].freeze.unshift('cat') }
 | 
			
		||||
    assert_raise(FrozenError) { [].freeze.unshift() }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_aref
 | 
			
		||||
| 
						 | 
				
			
			@ -2208,7 +2208,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    assert_equal([0, 1, 2], a.insert(-1, 2))
 | 
			
		||||
    assert_equal([0, 1, 3, 2], a.insert(-2, 3))
 | 
			
		||||
    assert_raise_with_message(IndexError, /-6/) { a.insert(-6, 4) }
 | 
			
		||||
    assert_raise(RuntimeError) { [0].freeze.insert(0)}
 | 
			
		||||
    assert_raise(FrozenError) { [0].freeze.insert(0)}
 | 
			
		||||
    assert_raise(ArgumentError) { [0].freeze.insert }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2389,8 +2389,8 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    assert_raise(ArgumentError) { a.flatten!(1, 2) }
 | 
			
		||||
    assert_raise(TypeError) { a.flatten!(:foo) }
 | 
			
		||||
    assert_raise(ArgumentError) { f.flatten!(1, 2) }
 | 
			
		||||
    assert_raise(RuntimeError) { f.flatten! }
 | 
			
		||||
    assert_raise(RuntimeError) { f.flatten!(:foo) }
 | 
			
		||||
    assert_raise(FrozenError) { f.flatten! }
 | 
			
		||||
    assert_raise(FrozenError) { f.flatten!(:foo) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_shuffle
 | 
			
		||||
| 
						 | 
				
			
			@ -2728,7 +2728,7 @@ class TestArray < Test::Unit::TestCase
 | 
			
		|||
    assert_equal([], a.rotate!(13))
 | 
			
		||||
    assert_equal([], a.rotate!(-13))
 | 
			
		||||
    a = [].freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /can\'t modify frozen/) {a.rotate!}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /can\'t modify frozen/) {a.rotate!}
 | 
			
		||||
    a = [1,2,3]
 | 
			
		||||
    assert_raise(ArgumentError) { a.rotate!(1, 1) }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -443,14 +443,14 @@ class TestClass < Test::Unit::TestCase
 | 
			
		|||
    obj = Object.new
 | 
			
		||||
    c = obj.singleton_class
 | 
			
		||||
    obj.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen object/) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen object/) {
 | 
			
		||||
      c.class_eval {def f; end}
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_singleton_class_message
 | 
			
		||||
    c = Class.new.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen Class/) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen Class/) {
 | 
			
		||||
      def c.f; end
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ class TestEnumerator < Test::Unit::TestCase
 | 
			
		|||
    enum = @obj.to_enum
 | 
			
		||||
    assert_raise(NoMethodError) { enum.each {} }
 | 
			
		||||
    enum.freeze
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      capture_io do
 | 
			
		||||
        # warning: Enumerator.new without a block is deprecated; use Object#to_enum
 | 
			
		||||
        enum.__send__(:initialize, @obj, :foo)
 | 
			
		||||
| 
						 | 
				
			
			@ -440,7 +440,7 @@ class TestEnumerator < Test::Unit::TestCase
 | 
			
		|||
    assert_equal([1, 2, 3], a)
 | 
			
		||||
 | 
			
		||||
    g.freeze
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      g.__send__ :initialize, proc { |y| y << 4 << 5 }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -506,7 +506,7 @@ class TestEval < Test::Unit::TestCase
 | 
			
		|||
  def test_fstring_instance_eval
 | 
			
		||||
    bug = "[ruby-core:78116] [Bug #12930]".freeze
 | 
			
		||||
    assert_same bug, (bug.instance_eval {self})
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      bug.instance_eval {@ivar = true}
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1031,8 +1031,8 @@ class TestHash < Test::Unit::TestCase
 | 
			
		|||
    assert_raise(TypeError) { h2.replace(1) }
 | 
			
		||||
    h2.freeze
 | 
			
		||||
    assert_raise(ArgumentError) { h2.replace() }
 | 
			
		||||
    assert_raise(RuntimeError) { h2.replace(h1) }
 | 
			
		||||
    assert_raise(RuntimeError) { h2.replace(42) }
 | 
			
		||||
    assert_raise(FrozenError) { h2.replace(h1) }
 | 
			
		||||
    assert_raise(FrozenError) { h2.replace(42) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_size2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,7 @@ class TestLazyEnumerator < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
    a = [1, 2, 3].lazy
 | 
			
		||||
    a.freeze
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      a.__send__ :initialize, [4, 5], &->(y, *v) { y << yield(*v) }
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -185,7 +185,7 @@ class TestRubyLiteral < Test::Unit::TestCase
 | 
			
		|||
      str = RubyVM::InstructionSequence.compile(src, f, f, n, opt).eval
 | 
			
		||||
      assert_equal("foo-1", str)
 | 
			
		||||
      assert_predicate(str, :frozen?)
 | 
			
		||||
      assert_raise_with_message(RuntimeError, /created at #{Regexp.quote(f)}:#{n}/) {
 | 
			
		||||
      assert_raise_with_message(FrozenError, /created at #{Regexp.quote(f)}:#{n}/) {
 | 
			
		||||
        str << "x"
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -568,7 +568,7 @@ class TestMarshal < Test::Unit::TestCase
 | 
			
		|||
    s.instance_variable_set(:@t, 42)
 | 
			
		||||
    t = Bug8276.new(s)
 | 
			
		||||
    s = Marshal.dump(t)
 | 
			
		||||
    assert_raise(RuntimeError) {Marshal.load(s)}
 | 
			
		||||
    assert_raise(FrozenError) {Marshal.load(s)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_marshal_load_ivar
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -636,15 +636,15 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
      def bar; end
 | 
			
		||||
    end
 | 
			
		||||
    m.freeze
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      m.module_eval do
 | 
			
		||||
        def foo; end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      m.__send__ :private, :bar
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      m.private_class_method :baz
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -949,7 +949,7 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
  def test_frozen_module
 | 
			
		||||
    m = Module.new
 | 
			
		||||
    m.freeze
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      m.instance_eval { undef_method(:foo) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -957,7 +957,7 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
  def test_frozen_class
 | 
			
		||||
    c = Class.new
 | 
			
		||||
    c.freeze
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      c.instance_eval { undef_method(:foo) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -967,7 +967,7 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
    o = klass.new
 | 
			
		||||
    c = class << o; self; end
 | 
			
		||||
    c.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) do
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) do
 | 
			
		||||
      c.instance_eval { undef_method(:foo) }
 | 
			
		||||
    end
 | 
			
		||||
    klass.class_eval do
 | 
			
		||||
| 
						 | 
				
			
			@ -2077,17 +2077,17 @@ class TestModule < Test::Unit::TestCase
 | 
			
		|||
    bug11532 = '[ruby-core:70828] [Bug #11532]'
 | 
			
		||||
 | 
			
		||||
    c = Class.new {const_set(:A, 1)}.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen class/, bug11532) {
 | 
			
		||||
      c.class_eval {private_constant :A}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    c = Class.new {const_set(:A, 1); private_constant :A}.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen class/, bug11532) {
 | 
			
		||||
      c.class_eval {public_constant :A}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    c = Class.new {const_set(:A, 1)}.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen class/, bug11532) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen class/, bug11532) {
 | 
			
		||||
      c.class_eval {deprecate_constant :A}
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,12 +99,12 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
  def test_taint_frozen_obj
 | 
			
		||||
    o = Object.new
 | 
			
		||||
    o.freeze
 | 
			
		||||
    assert_raise(RuntimeError) { o.taint }
 | 
			
		||||
    assert_raise(FrozenError) { o.taint }
 | 
			
		||||
 | 
			
		||||
    o = Object.new
 | 
			
		||||
    o.taint
 | 
			
		||||
    o.freeze
 | 
			
		||||
    assert_raise(RuntimeError) { o.untaint }
 | 
			
		||||
    assert_raise(FrozenError) { o.untaint }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_freeze_immediate
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
      attr_accessor :foo
 | 
			
		||||
    }
 | 
			
		||||
    obj = klass.new.freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /#{name}/) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /#{name}/) {
 | 
			
		||||
      obj.foo = 1
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -399,7 +399,7 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
  def test_remove_method
 | 
			
		||||
    c = Class.new
 | 
			
		||||
    c.freeze
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      c.instance_eval { remove_method(:foo) }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -807,7 +807,7 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
    class<<x;self;end.class_eval {define_method(:to_s) {name}}
 | 
			
		||||
    assert_same(name, x.to_s)
 | 
			
		||||
    assert_not_predicate(name, :tainted?)
 | 
			
		||||
    assert_raise(RuntimeError) {name.taint}
 | 
			
		||||
    assert_raise(FrozenError) {name.taint}
 | 
			
		||||
    assert_equal("X", [x].join(""))
 | 
			
		||||
    assert_not_predicate(name, :tainted?)
 | 
			
		||||
    assert_not_predicate(eval('"X".freeze'), :tainted?)
 | 
			
		||||
| 
						 | 
				
			
			@ -899,7 +899,7 @@ class TestObject < Test::Unit::TestCase
 | 
			
		|||
    b = yield
 | 
			
		||||
    assert_nothing_raised("copy") {a.instance_eval {initialize_copy(b)}}
 | 
			
		||||
    c = a.dup.freeze
 | 
			
		||||
    assert_raise(RuntimeError, "frozen") {c.instance_eval {initialize_copy(b)}}
 | 
			
		||||
    assert_raise(FrozenError, "frozen") {c.instance_eval {initialize_copy(b)}}
 | 
			
		||||
    d = a.dup.trust
 | 
			
		||||
    [a, b, c, d]
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -821,7 +821,7 @@ EXPECTED
 | 
			
		|||
  def test_pack_with_buffer
 | 
			
		||||
    buf = String.new(capacity: 100)
 | 
			
		||||
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {
 | 
			
		||||
      [0xDEAD_BEEF].pack('N', buffer: 'foo'.freeze)
 | 
			
		||||
    }
 | 
			
		||||
    assert_raise_with_message(TypeError, /must be String/) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -507,7 +507,7 @@ END
 | 
			
		|||
  def test_initialize_frozen
 | 
			
		||||
    r = Random.new(0)
 | 
			
		||||
    r.freeze
 | 
			
		||||
    assert_raise(RuntimeError, '[Bug #6540]') do
 | 
			
		||||
    assert_raise(FrozenError, '[Bug #6540]') do
 | 
			
		||||
      r.__send__(:initialize, r)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -516,7 +516,7 @@ END
 | 
			
		|||
    r = Random.new(0)
 | 
			
		||||
    d = r.__send__(:marshal_dump)
 | 
			
		||||
    r.freeze
 | 
			
		||||
    assert_raise(RuntimeError, '[Bug #6540]') do
 | 
			
		||||
    assert_raise(FrozenError, '[Bug #6540]') do
 | 
			
		||||
      r.__send__(:marshal_load, d)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ class TestRange < Test::Unit::TestCase
 | 
			
		|||
  def test_frozen_initialize
 | 
			
		||||
    r = Range.allocate
 | 
			
		||||
    r.freeze
 | 
			
		||||
    assert_raise(RuntimeError){r.__send__(:initialize, 1, 2)}
 | 
			
		||||
    assert_raise(FrozenError){r.__send__(:initialize, 1, 2)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_range_string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -928,7 +928,7 @@ class TestRubyOptions < Test::Unit::TestCase
 | 
			
		|||
 | 
			
		||||
  def test_frozen_string_literal_debug
 | 
			
		||||
    with_debug_pat = /created at/
 | 
			
		||||
    wo_debug_pat = /can\'t modify frozen String \(RuntimeError\)\n\z/
 | 
			
		||||
    wo_debug_pat = /can\'t modify frozen String \(FrozenError\)\n\z/
 | 
			
		||||
    frozen = [
 | 
			
		||||
      ["--enable-frozen-string-literal", true],
 | 
			
		||||
      ["--disable-frozen-string-literal", false],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,12 +62,12 @@ class TestString < Test::Unit::TestCase
 | 
			
		|||
  def test_initialize
 | 
			
		||||
    str = S("").freeze
 | 
			
		||||
    assert_equal("", str.__send__(:initialize))
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, 'abc') }
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, capacity: 1000) }
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, 'abc', capacity: 1000) }
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, encoding: 'euc-jp') }
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, 'abc', encoding: 'euc-jp') }
 | 
			
		||||
    assert_raise(RuntimeError){ str.__send__(:initialize, 'abc', capacity: 1000, encoding: 'euc-jp') }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, 'abc') }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, capacity: 1000) }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, 'abc', capacity: 1000) }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, encoding: 'euc-jp') }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, 'abc', encoding: 'euc-jp') }
 | 
			
		||||
    assert_raise(FrozenError){ str.__send__(:initialize, 'abc', capacity: 1000, encoding: 'euc-jp') }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_initialize_nonstring
 | 
			
		||||
| 
						 | 
				
			
			@ -491,7 +491,7 @@ CODE
 | 
			
		|||
    assert_equal(S("a").hash, S("a\u0101").chomp!(S("\u0101")).hash, '[ruby-core:22414]')
 | 
			
		||||
 | 
			
		||||
    s = S("").freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.chomp!}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.chomp!}
 | 
			
		||||
 | 
			
		||||
    s = S("ax")
 | 
			
		||||
    o = Struct.new(:s).new(s)
 | 
			
		||||
| 
						 | 
				
			
			@ -499,7 +499,7 @@ CODE
 | 
			
		|||
      s.freeze
 | 
			
		||||
      "x"
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.chomp!(o)}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.chomp!(o)}
 | 
			
		||||
 | 
			
		||||
    s = S("hello")
 | 
			
		||||
    assert_equal("hel", s.chomp!('lo'))
 | 
			
		||||
| 
						 | 
				
			
			@ -617,7 +617,7 @@ CODE
 | 
			
		|||
    expected = S("\u0300".encode(Encoding::UTF_16LE))
 | 
			
		||||
    assert_equal(expected, result, bug7090)
 | 
			
		||||
    assert_raise(TypeError) { 'foo' << :foo }
 | 
			
		||||
    assert_raise(RuntimeError) { 'foo'.freeze.concat('bar') }
 | 
			
		||||
    assert_raise(FrozenError) { 'foo'.freeze.concat('bar') }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_concat_literals
 | 
			
		||||
| 
						 | 
				
			
			@ -1367,10 +1367,10 @@ CODE
 | 
			
		|||
    assert_equal(s2, s)
 | 
			
		||||
 | 
			
		||||
    fs = "".freeze
 | 
			
		||||
    assert_raise(RuntimeError) { fs.replace("a") }
 | 
			
		||||
    assert_raise(RuntimeError) { fs.replace(fs) }
 | 
			
		||||
    assert_raise(FrozenError) { fs.replace("a") }
 | 
			
		||||
    assert_raise(FrozenError) { fs.replace(fs) }
 | 
			
		||||
    assert_raise(ArgumentError) { fs.replace() }
 | 
			
		||||
    assert_raise(RuntimeError) { fs.replace(42) }
 | 
			
		||||
    assert_raise(FrozenError) { fs.replace(42) }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_reverse
 | 
			
		||||
| 
						 | 
				
			
			@ -2272,7 +2272,7 @@ CODE
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_frozen_check
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      s = ""
 | 
			
		||||
      s.sub!(/\A/) { s.freeze; "zzz" }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -2710,7 +2710,7 @@ CODE
 | 
			
		|||
    assert_equal("bba", s)
 | 
			
		||||
 | 
			
		||||
    s = S("ax").freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.delete_prefix!("a")}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.delete_prefix!("a")}
 | 
			
		||||
 | 
			
		||||
    s = S("ax")
 | 
			
		||||
    o = Struct.new(:s).new(s)
 | 
			
		||||
| 
						 | 
				
			
			@ -2718,7 +2718,7 @@ CODE
 | 
			
		|||
      s.freeze
 | 
			
		||||
      "a"
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.delete_prefix!(o)}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.delete_prefix!(o)}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_delete_suffix
 | 
			
		||||
| 
						 | 
				
			
			@ -2778,7 +2778,7 @@ CODE
 | 
			
		|||
    assert_raise(TypeError) { 'hello'.delete_suffix!(/hel/) }
 | 
			
		||||
 | 
			
		||||
    s = S("hello").freeze
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.delete_suffix!('lo')}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.delete_suffix!('lo')}
 | 
			
		||||
 | 
			
		||||
    s = S("ax")
 | 
			
		||||
    o = Struct.new(:s).new(s)
 | 
			
		||||
| 
						 | 
				
			
			@ -2786,7 +2786,7 @@ CODE
 | 
			
		|||
      s.freeze
 | 
			
		||||
      "x"
 | 
			
		||||
    end
 | 
			
		||||
    assert_raise_with_message(RuntimeError, /frozen/) {s.delete_suffix!(o)}
 | 
			
		||||
    assert_raise_with_message(FrozenError, /frozen/) {s.delete_suffix!(o)}
 | 
			
		||||
 | 
			
		||||
    s = S("hello")
 | 
			
		||||
    assert_equal("hel", s.delete_suffix!('lo'))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ class TestThread < Test::Unit::TestCase
 | 
			
		|||
  def test_thread_variable_frozen
 | 
			
		||||
    t = Thread.new { }.join
 | 
			
		||||
    t.freeze
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      t.thread_variable_set(:foo, "bar")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -547,7 +547,7 @@ class TestThread < Test::Unit::TestCase
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def test_thread_local_security
 | 
			
		||||
    assert_raise(RuntimeError) do
 | 
			
		||||
    assert_raise(FrozenError) do
 | 
			
		||||
      Thread.new do
 | 
			
		||||
        Thread.current[:foo] = :bar
 | 
			
		||||
        Thread.current.freeze
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,8 +13,8 @@ class TestTranscode < Test::Unit::TestCase
 | 
			
		|||
    assert_raise(Encoding::UndefinedConversionError) { "\x80".encode('utf-8','ASCII-8BIT') }
 | 
			
		||||
    assert_raise(Encoding::InvalidByteSequenceError) { "\x80".encode('utf-8','US-ASCII') }
 | 
			
		||||
    assert_raise(Encoding::UndefinedConversionError) { "\xA5".encode('utf-8','iso-8859-3') }
 | 
			
		||||
    assert_raise(RuntimeError) { 'hello'.freeze.encode!('iso-8859-1') }
 | 
			
		||||
    assert_raise(RuntimeError) { '\u3053\u3093\u306b\u3061\u306f'.freeze.encode!('iso-8859-1') } # こんにちは
 | 
			
		||||
    assert_raise(FrozenError) { 'hello'.freeze.encode!('iso-8859-1') }
 | 
			
		||||
    assert_raise(FrozenError) { '\u3053\u3093\u306b\u3061\u306f'.freeze.encode!('iso-8859-1') } # こんにちは
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_arguments
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,14 +137,14 @@ class TestVariable < Test::Unit::TestCase
 | 
			
		|||
      assert_empty v.instance_variables
 | 
			
		||||
      msg = "can't modify frozen #{v.class}"
 | 
			
		||||
 | 
			
		||||
      assert_raise_with_message(RuntimeError, msg) do
 | 
			
		||||
      assert_raise_with_message(FrozenError, msg) do
 | 
			
		||||
        v.instance_variable_set(:@foo, :bar)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      assert_nil EnvUtil.suppress_warning {v.instance_variable_get(:@foo)}
 | 
			
		||||
      assert_not_send([v, :instance_variable_defined?, :@foo])
 | 
			
		||||
 | 
			
		||||
      assert_raise_with_message(RuntimeError, msg) do
 | 
			
		||||
      assert_raise_with_message(FrozenError, msg) do
 | 
			
		||||
        v.remove_instance_variable(:@foo)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -722,9 +722,9 @@ class TestStringIO < Test::Unit::TestCase
 | 
			
		|||
    s = StringIO.new
 | 
			
		||||
    s.freeze
 | 
			
		||||
    bug = '[ruby-core:33648]'
 | 
			
		||||
    assert_raise(RuntimeError, bug) {s.puts("foo")}
 | 
			
		||||
    assert_raise(RuntimeError, bug) {s.string = "foo"}
 | 
			
		||||
    assert_raise(RuntimeError, bug) {s.reopen("")}
 | 
			
		||||
    assert_raise(FrozenError, bug) {s.puts("foo")}
 | 
			
		||||
    assert_raise(FrozenError, bug) {s.string = "foo"}
 | 
			
		||||
    assert_raise(FrozenError, bug) {s.reopen("")}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_frozen_string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ class TestDelegateClass < Test::Unit::TestCase
 | 
			
		|||
    a = [42, :hello].freeze
 | 
			
		||||
    d = SimpleDelegator.new(a)
 | 
			
		||||
    assert_nothing_raised(bug2679) {d.dup[0] += 1}
 | 
			
		||||
    assert_raise(RuntimeError) {d.clone[0] += 1}
 | 
			
		||||
    assert_raise(FrozenError) {d.clone[0] += 1}
 | 
			
		||||
    d.freeze
 | 
			
		||||
    assert(d.clone.frozen?)
 | 
			
		||||
    assert(!d.dup.frozen?)
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ class TestDelegateClass < Test::Unit::TestCase
 | 
			
		|||
  def test_frozen
 | 
			
		||||
    d = SimpleDelegator.new([1, :foo])
 | 
			
		||||
    d.freeze
 | 
			
		||||
    assert_raise(RuntimeError, '[ruby-dev:40314]#1') {d.__setobj__("foo")}
 | 
			
		||||
    assert_raise(FrozenError, '[ruby-dev:40314]#1') {d.__setobj__("foo")}
 | 
			
		||||
    assert_equal([1, :foo], d)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -693,7 +693,7 @@ class TC_Set < Test::Unit::TestCase
 | 
			
		|||
    set << 4
 | 
			
		||||
    assert_same orig, set.freeze
 | 
			
		||||
    assert_equal true, set.frozen?
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      set << 5
 | 
			
		||||
    }
 | 
			
		||||
    assert_equal 4, set.size
 | 
			
		||||
| 
						 | 
				
			
			@ -716,7 +716,7 @@ class TC_Set < Test::Unit::TestCase
 | 
			
		|||
    set2 = set1.clone
 | 
			
		||||
 | 
			
		||||
    assert_predicate set2, :frozen?
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      set2.add 5
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -849,7 +849,7 @@ class TC_SortedSet < Test::Unit::TestCase
 | 
			
		|||
    set << 4
 | 
			
		||||
    assert_same orig, set.freeze
 | 
			
		||||
    assert_equal true, set.frozen?
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      set << 5
 | 
			
		||||
    }
 | 
			
		||||
    assert_equal 4, set.size
 | 
			
		||||
| 
						 | 
				
			
			@ -877,7 +877,7 @@ class TC_SortedSet < Test::Unit::TestCase
 | 
			
		|||
    set2 = set1.clone
 | 
			
		||||
 | 
			
		||||
    assert_predicate set2, :frozen?
 | 
			
		||||
    assert_raise(RuntimeError) {
 | 
			
		||||
    assert_raise(FrozenError) {
 | 
			
		||||
      set2.add 5
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue