ruby-changes:67998
From: Shugo <ko1@a...>
Date: Wed, 15 Sep 2021 16:12:24 +0900 (JST)
Subject: [ruby-changes:67998] fae0f2486d (master): Add test cases for constants and keywords
https://git.ruby-lang.org/ruby.git/commit/?id=fae0f2486d From fae0f2486dd9768b7e20b9cf67166fe935f18b0f Mon Sep 17 00:00:00 2001 From: Shugo Maeda <shugo@r...> 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(+) diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index ccfe1b1..3a8ff78 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -506,12 +506,19 @@ class TestRubyLiteral < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_literal.rb#L506 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.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/