1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add test cases for constants and keywords

This commit is contained in:
Shugo Maeda 2021-09-15 16:10:42 +09:00
parent a27c274f04
commit fae0f2486d
No known key found for this signature in database
GPG key ID: 2DFE34085E97CE47

View file

@ -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