diff options
author | zverok <zverok.offline@gmail.com> | 2022-10-19 22:07:23 +0300 |
---|---|---|
committer | Victor Shepelev <zverok.offline@gmail.com> | 2022-11-22 23:10:46 +0200 |
commit | eaf2b6c4396ff19921cbc75a394d7a752aaab4ef (patch) | |
tree | ff275ee65e937f17232c64a8c66d5ed258cb15de /test/ruby/test_time.rb | |
parent | 63f4a7a1ec3433cc985503e3ca342e4a9ebda257 (diff) | |
download | ruby-eaf2b6c4396ff19921cbc75a394d7a752aaab4ef.tar.gz |
Add Time#deconstruct_keys
Diffstat (limited to 'test/ruby/test_time.rb')
-rw-r--r-- | test/ruby/test_time.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 4af4cf5474..da87de62a5 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -1329,4 +1329,18 @@ class TestTime < Test::Unit::TestCase rescue LoadError => e omit "failed to load objspace: #{e.message}" end + + def test_deconstruct_keys + t = in_timezone('JST-9') { Time.local(2022, 10, 16, 14, 1, 30, 500) } + assert_equal( + {year: 2022, month: 10, day: 16, wday: 0, yday: 289, + hour: 14, min: 1, sec: 30, subsec: 1/2000r, dst: false, zone: 'JST'}, + t.deconstruct_keys(nil) + ) + + assert_equal( + {year: 2022, month: 10, sec: 30}, + t.deconstruct_keys(%i[year month sec nonexistent]) + ) + end end |