diff options
Diffstat (limited to 'spec/ruby')
| -rw-r--r-- | spec/ruby/core/exception/frozen_error_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/ruby/core/exception/frozen_error_spec.rb b/spec/ruby/core/exception/frozen_error_spec.rb new file mode 100644 index 0000000000..7b356253c4 --- /dev/null +++ b/spec/ruby/core/exception/frozen_error_spec.rb @@ -0,0 +1,34 @@ +require_relative '../../spec_helper' + +describe "FrozenError" do + ruby_version_is "2.5" do + it "is a subclass of RuntimeError" do + RuntimeError.should be_ancestor_of(FrozenError) + end + end +end + +describe "FrozenError.new" do + ruby_version_is "2.7" do + it "should take optional receiver argument" do + o = Object.new + FrozenError.new("msg", o).receiver.should equal(o) + end + end +end + +describe "FrozenError#receiver" do + ruby_version_is "2.7" do + it "should return frozen object that modification was attempted on" do + o = Object.new.freeze + begin + def o.x; end + rescue => e + e.should be_kind_of(FrozenError) + e.receiver.should equal(o) + else + raise + end + end + end +end |
