summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_literal.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb
index ccfe1b1919..3a8ff7857f 100644
--- a/test/ruby/test_literal.rb
+++ b/test/ruby/test_literal.rb
@@ -506,12 +506,19 @@ class TestRubyLiteral < Test::Unit::TestCase
assert_equal(100, h['a'])
end
+ FOO = "foo"
+
def test_hash_value_omission
x = 1
y = 2
assert_equal({x: 1, y: 2}, {x:, y:})
assert_equal({x: 1, y: 2, z: 3}, {x:, y:, z: 3})
assert_equal({one: 1, two: 2}, {one:, two:})
+ b = binding
+ b.local_variable_set(:if, "if")
+ b.local_variable_set(:self, "self")
+ assert_equal({FOO: "foo", if: "if", self: "self"},
+ eval('{FOO:, if:, self:}', b))
assert_syntax_error('{"#{x}":}', /'\}'/)
end