summaryrefslogtreecommitdiff
path: root/test/ruby/test_literal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_literal.rb')
-rw-r--r--test/ruby/test_literal.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index 579a39dee8..c8a65c923a 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -506,6 +506,22 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal(100, h['a'])
end
+ def test_hash_value_omission
+ x = 1
+ y = 2
+ assert_equal({x: 1, y: 2}, {x:, y:})
+ assert_equal({one: 1, two: 2}, {one:, two:})
+ assert_syntax_error('{"#{x}":}', /'\}'/)
+ end
+
+ private def one
+ 1
+ end
+
+ private def two
+ 2
+ end
+
def test_range
assert_instance_of Range, (1..2)
assert_equal(1..2, 1..2)