summaryrefslogtreecommitdiff
path: root/test/json/json_generator_test.rb
diff options
context:
space:
mode:
authorÉtienne Barrié <[email protected]>2025-01-20 11:12:09 +0100
committerJean Boussier <[email protected]>2025-01-20 14:20:55 +0100
commite8676cada82ed9947502b416eaa948258a62d7b9 (patch)
tree05dbf50a935789222337d04b1edc230b296de02b /test/json/json_generator_test.rb
parentba44e92573f5fdd23d29cfb49d8afe78287d5f79 (diff)
[ruby/json] Introduce JSON::Fragment
https://github.com/ruby/json/commit/9e3500f345 Co-authored-by: Jean Boussier <[email protected]>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12602
Diffstat (limited to 'test/json/json_generator_test.rb')
-rwxr-xr-xtest/json/json_generator_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb
index 8dd3913d62..824de2c1a6 100755
--- a/test/json/json_generator_test.rb
+++ b/test/json/json_generator_test.rb
@@ -661,4 +661,9 @@ class JSONGeneratorTest < Test::Unit::TestCase
def test_nonutf8_encoding
assert_equal("\"5\u{b0}\"", "5\xb0".dup.force_encoding(Encoding::ISO_8859_1).to_json)
end
+
+ def test_fragment
+ fragment = JSON::Fragment.new(" 42")
+ assert_equal '{"number": 42}', JSON.generate({ number: fragment })
+ end
end