8000 Revert "To use RuntimeError instead of FrozenError for old ruby versi… · ruby/ostruct@ed5ff5b · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit ed5ff5b

Browse files
committed
Revert "To use RuntimeError instead of FrozenError for old ruby versions."
This reverts commit 4cd1fc8.
1 parent d186d42 commit ed5ff5b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/ostruct.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ def modifiable? # :nodoc:
170170
begin
171171
@modifiable = true
172172
rescue
173-
exception_class = defined?(FrozenError) ? FrozenError : RuntimeError
174-
raise exception_class, "can't modify frozen #{self.class}", caller(3)
173+
raise FrozenError, "can't modify frozen #{self.class}", caller(3)
175174
end
176175
@table
177176
end

test/ostruct/test_ostruct.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,15 @@ def test_frozen
6666
o = OpenStruct.new(foo: 42)
6767
o.a = 'a'
6868
o.freeze
69-
expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
70-
assert_raise(expected_error) {o.b = 'b'}
69+
assert_raise(FrozenError) {o.b = 'b'}
7170
assert_not_respond_to(o, :b)
72-
assert_raise(expected_error) {o.a = 'z'}
71+
assert_raise(FrozenError) {o.a = 'z'}
7372
assert_equal('a', o.a)
7473
assert_equal(42, o.foo)
7574
o = OpenStruct.new :a => 42
7675
def o.frozen?; nil end
7776
o.freeze
78-
assert_raise(expected_error, '[ruby-core:22559]') {o.a = 1764}
77+
assert_raise(FrozenError, '[ruby-core:22559]') {o.a = 1764}
7978
end
8079

8180
def test_delete_field

0 commit comments

Comments
 (0)
0