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:
parent
a27c274f04
commit
fae0f2486d
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue