Use Time.new because JSON.unsafe_load losts fractions of a second and

JSON.unsafe_load with Time object returns String

```
  1) Failure:
JSONCommonInterfaceTest#test_unsafe_load_default_options [/path/to/ruby/test/json/json_common_interface_test.rb:230]:
<2025-09-03 14:28:31.293635 +0200> expected but was
<"2025-09-03 14:28:31 +0200">.
```
This commit is contained in:
Hiroshi SHIBATA 2025-09-03 14:41:10 +02:00
parent 9af5af2c7d
commit 837d74104c

View File

@ -226,8 +226,8 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
nan_json = '{ "foo": NaN }'
assert JSON.unsafe_load(nan_json, nil)['foo'].nan?
assert_equal nil, JSON.unsafe_load(nil, nil)
t = Time.now
assert_equal t, JSON.unsafe_load(JSON(t))
t = Time.new(2025, 9, 3, 14, 50, 0)
assert_equal t.to_s, JSON.unsafe_load(JSON(t)).to_s
end
def test_unsafe_load_with_options