summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-07 12:47:11 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-07 12:47:11 +0000
commit1380aa04a6c3681a232046058f4388f3bce904ae (patch)
tree9650337a0e4bcccb9a73cdc11e83bd6e3e42511e /test
parentd59fc41fbaf6ae3458a5260fb53916468f7e56f7 (diff)
Support old versions of Ruby with FrozenError.
They should work separatedly from Ruby core repository. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/date/test_date_marshal.rb6
-rw-r--r--test/dbm/test_dbm.rb3
-rw-r--r--test/gdbm/test_gdbm.rb3
-rw-r--r--test/ostruct/test_ostruct.rb7
-rw-r--r--test/stringio/test_stringio.rb7
5 files changed, 16 insertions, 10 deletions
diff --git a/test/date/test_date_marshal.rb b/test/date/test_date_marshal.rb
index 99a7239f95..24622bd4b9 100644
--- a/test/date/test_date_marshal.rb
+++ b/test/date/test_date_marshal.rb
@@ -30,13 +30,15 @@ class TestDateMarshal < Test::Unit::TestCase
a = d.marshal_dump
d.freeze
assert(d.frozen?)
- assert_raise(FrozenError){d.marshal_load(a)}
+ expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
+ assert_raise(expected_error){d.marshal_load(a)}
d = DateTime.now
a = d.marshal_dump
d.freeze
assert(d.frozen?)
- assert_raise(FrozenError){d.marshal_load(a)}
+ expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
+ assert_raise(expected_error){d.marshal_load(a)}
end
end
diff --git a/test/dbm/test_dbm.rb b/test/dbm/test_dbm.rb
index 874b326404..d7cb5497fc 100644
--- a/test/dbm/test_dbm.rb
+++ b/test/dbm/test_dbm.rb
@@ -625,9 +625,10 @@ if defined? DBM
end
def test_freeze
+ expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
DBM.open("#{@tmproot}/a") {|d|
d.freeze
- assert_raise(FrozenError) { d["k"] = "v" }
+ assert_raise(expected_error) { d["k"] = "v" }
}
end
end
diff --git a/test/gdbm/test_gdbm.rb b/test/gdbm/test_gdbm.rb
index 39f87d7d8a..64692a4465 100644
--- a/test/gdbm/test_gdbm.rb
+++ b/test/gdbm/test_gdbm.rb
@@ -726,7 +726,8 @@ if defined? GDBM
def test_freeze
GDBM.open("#{@tmproot}/a.dbm") {|d|
d.freeze
- assert_raise(FrozenError) { d["k"] = "v" }
+ expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
+ assert_raise(expected_error) { d["k"] = "v" }
}
end
end
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index a15de36c23..d89bc94cc3 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -66,15 +66,16 @@ class TC_OpenStruct < Test::Unit::TestCase
o = OpenStruct.new(foo: 42)
o.a = 'a'
o.freeze
- assert_raise(FrozenError) {o.b = 'b'}
+ expected_error = defined?(FrozenError) ? FrozenError : RuntimeError
+ assert_raise(expected_error) {o.b = 'b'}
assert_not_respond_to(o, :b)
- assert_raise(FrozenError) {o.a = 'z'}
+ assert_raise(expected_error) {o.a = 'z'}
assert_equal('a', o.a)
assert_equal(42, o.foo)
o = OpenStruct.new :a => 42
def o.frozen?; nil end
o.freeze
- assert_raise(FrozenError, '[ruby-core:22559]') {o.a = 1764}
+ assert_raise(expected_error, '[ruby-core:22559]') {o.a = 1764}
end
def test_delete_field
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index f5169f641a..89da34e4ec 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -722,9 +722,10 @@ class TestStringIO < Test::Unit::TestCase
s = StringIO.new
s.freeze
bug = '[ruby-core:33648]'
- assert_raise(FrozenError, bug) {s.puts("foo")}
- assert_raise(FrozenError, bug) {s.string = "foo"}
- assert_raise(FrozenError, bug) {s.reopen("")}
+ exception_class = defined?(FrozenError) ? FrozenError : RuntimeError
+ assert_raise(exception_class, bug) {s.puts("foo")}
+ assert_raise(exception_class, bug) {s.string = "foo"}
+ assert_raise(exception_class, bug) {s.reopen("")}
end
def test_frozen_string