summaryrefslogtreecommitdiff
path: root/test/ruby/test_literal.rb
diff options
context:
space:
mode:
authorShugo Maeda <shugo@ruby-lang.org>2021-09-15 16:10:42 +0900
committerShugo Maeda <shugo@ruby-lang.org>2021-09-15 16:11:40 +0900
commitfae0f2486dd9768b7e20b9cf67166fe935f18b0f (patch)
treeabda81012ac48856dc83230fb4604d838be9f4ca /test/ruby/test_literal.rb
parenta27c274f0476fa270b9e2f5d4f4ec36bd8c0b61a (diff)
Add test cases for constants and keywords
Diffstat (limited to 'test/ruby/test_literal.rb')
-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