From fae0f2486dd9768b7e20b9cf67166fe935f18b0f Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Wed, 15 Sep 2021 16:10:42 +0900 Subject: Add test cases for constants and keywords --- test/ruby/test_literal.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby/test_literal.rb') 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 -- cgit v1.2.3