diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-12 00:46:34 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-12 00:46:34 +0000 |
commit | b57915eddc91ce0369ae8bcf82d8c4364f42ea05 (patch) | |
tree | c5296c8fd95c9ee041fe66455eb0744c3212b5c5 /test/ruby/test_object.rb | |
parent | 0b31ce0047513d1eb8f9902286215025a3742bf5 (diff) |
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 <[email protected]>
Signed-off-by: Urabe Shyouhei <[email protected]>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_object.rb')
-rw-r--r-- | test/ruby/test_object.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index e55a09dc23..c25dcf9c37 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -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 |