diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-10-29 18:12:32 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-10-29 10:03:50 +0000 |
| commit | 0f629083722a09f0b5a75040ca0511e71eb6032a (patch) | |
| tree | d9a1736041243143b7aba775823f6135cff3be53 | |
| parent | 12350eb9e0d3317da57b5a37c0c2810946b48850 (diff) | |
[ruby/date] Prefer `method_defined?` over `allocate.respond_to?`
https://github.com/ruby/date/commit/fd8e3725f8
| -rw-r--r-- | test/date/test_date_conv.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/date/test_date_conv.rb b/test/date/test_date_conv.rb index 772fbee9a4..c54a118f8f 100644 --- a/test/date/test_date_conv.rb +++ b/test/date/test_date_conv.rb @@ -82,7 +82,7 @@ class TestDateConv < Test::Unit::TestCase assert_equal([1582, 10, 13, 1, 2, 3, 456789], [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.usec]) - if Time.allocate.respond_to?(:nsec) + if Time.method_defined?(:nsec) d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123.to_r/86400000000000 t = d.to_time.utc assert_equal([2004, 9, 19, 1, 2, 3, 456789123], @@ -91,7 +91,7 @@ class TestDateConv < Test::Unit::TestCase # TruffleRuby does not support more than nanoseconds unless RUBY_ENGINE == 'truffleruby' - if Time.allocate.respond_to?(:subsec) + if Time.method_defined?(:subsec) d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000 t = d.to_time.utc assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)], |
