1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/date] Use assert_deprecated_warn

https://github.com/ruby/date/commit/c55004715a
This commit is contained in:
Nobuyoshi Nakada 2022-02-25 20:34:59 +09:00 committed by git
parent 0db5ee5195
commit 8780f15fd7
2 changed files with 8 additions and 8 deletions

View file

@ -864,7 +864,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._iso8601(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._iso8601('01-02-03T04:05:06Z'.to_sym)}
h = assert_deprecated_warn {Date._iso8601('01-02-03T04:05:06Z'.to_sym)}
assert_equal([2001, 2, 3, 4, 5, 6, 0],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
@ -886,7 +886,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._rfc3339(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)}
h = assert_deprecated_warn {Date._rfc3339('2001-02-03T04:05:06Z'.to_sym)}
assert_equal([2001, 2, 3, 4, 5, 6, 0],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
@ -975,7 +975,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._xmlschema(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._xmlschema('2001-02-03'.to_sym)}
h = assert_deprecated_warn {Date._xmlschema('2001-02-03'.to_sym)}
assert_equal([2001, 2, 3, nil, nil, nil, nil],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
@ -1014,7 +1014,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._rfc2822(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)}
h = assert_deprecated_warn {Date._rfc2822('Sat, 3 Feb 2001 04:05:06 UT'.to_sym)}
assert_equal([2001, 2, 3, 4, 5, 6, 0],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
@ -1041,7 +1041,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._httpdate(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)}
h = assert_deprecated_warn {Date._httpdate('Sat, 03 Feb 2001 04:05:06 GMT'.to_sym)}
assert_equal([2001, 2, 3, 4, 5, 6, 0],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end
@ -1124,7 +1124,7 @@ class TestDateParse < Test::Unit::TestCase
h = Date._jisx0301(nil)
assert_equal({}, h)
h = assert_warn(/deprecated/) {Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)}
h = assert_deprecated_warn {Date._jisx0301('H13.02.03T04:05:06.07+0100'.to_sym)}
assert_equal([2001, 2, 3, 4, 5, 6, 3600],
h.values_at(:year, :mon, :mday, :hour, :min, :sec, :offset))
end

View file

@ -592,14 +592,14 @@ eom
def assert_deprecated_warning(mesg = /deprecated/)
assert_warning(mesg) do
Warning[:deprecated] = true
Warning[:deprecated] = true if Warning.respond_to?(:[]=)
yield
end
end
def assert_deprecated_warn(mesg = /deprecated/)
assert_warn(mesg) do
Warning[:deprecated] = true
Warning[:deprecated] = true if Warning.respond_to?(:[]=)
yield
end
end