Skip to content

Commit 8b96619

Browse files
rwstaunermatzbot
authored andcommitted
[ruby/json] Fix json generation for symbols on TruffleRuby
ruby/json@0e99fcb581
1 parent 3588198 commit 8b96619

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

test/json/json_coder_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def test_json_coder_with_proc_with_unsupported_value
1919
assert_raise(JSON::GeneratorError) { coder.dump([Object.new]) }
2020
end
2121

22+
def test_json_coder_with_proc_returning_symbol
23+
coder = JSON::Coder.new { _1 }
24+
assert_equal %({"sym":"sym"}), coder.dump({ sym: :sym })
25+
end
26+
2227
def test_json_coder_hash_key
2328
obj = Object.new
2429
coder = JSON::Coder.new do |obj, is_key|

test/json/json_generator_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def test_dump_strict
8282
assert_equal '"hello"', dump(:hello, strict: true)
8383
assert_equal '"hello"', :hello.to_json(strict: true)
8484
assert_equal '"World"', "World".to_json(strict: true)
85+
assert_equal '["hello"]', dump([:hello], strict: true)
86+
assert_equal '{"hello":"world"}', dump({ hello: :world }, strict: true)
8587
end
8688

8789
def test_not_frozen

0 commit comments

Comments
 (0)