diff options
author | eno <[email protected]> | 2025-03-19 22:48:08 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-03-24 14:35:04 +0900 |
commit | 528c08cc5fe8f8c990442885c0a30c95d8798e55 (patch) | |
tree | 18cd9ec53e3e7384e78644cb0cca334326b28bc1 /test/json/json_generator_test.rb | |
parent | a59333c58bbe0df0baaada6d3cc4a64b0aaf911e (diff) |
[ruby/json] Adjust fpconv to add ".0" to integers
Adds a test case
fix
https://github.com/ruby/json/commit/fa5bdf87cb
Diffstat (limited to 'test/json/json_generator_test.rb')
-rwxr-xr-x | test/json/json_generator_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 4a92801fe1..bf4796a6bf 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -698,4 +698,13 @@ class JSONGeneratorTest < Test::Unit::TestCase object = Object.new assert_equal object.object_id.to_json, JSON.generate(object, strict: true, as_json: :object_id) end + + def test_json_generate_float + values = [-1.0, 1.0, 0.0, 12.2, 7.5 / 3.2, 12.0, 100.0, 1000.0] + expecteds = ["-1.0", "1.0", "0.0", "12.2", "2.34375", "12.0", "100.0", "1000.0"] + + values.zip(expecteds).each do |value, expected| + assert_equal expected, value.to_json + end + end end |