aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-02 08:21:30 -0700
committerGitHub <noreply@github.com>2019-09-02 08:21:30 -0700
commitf560609d66502101264706877577220e3ebf5a38 (patch)
treed30a77b807ed0d4eb5363270b7119f1f31165b54 /test
parentbe86591458c5f29db0d97601f29e15e43d5fe23c (diff)
downloadruby-f560609d66502101264706877577220e3ebf5a38.tar.gz
Merge pull request #2418 from jeremyevans/array-empty-kwsplat
Ignore empty keyword splats in arrays
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index b98a233937..56e2937dc8 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -100,6 +100,33 @@ class TestSyntax < Test::Unit::TestCase
EOS
end
+ def test_array_kwsplat_hash
+ kw = {}
+ h = {a: 1}
+ assert_equal([], [**{}])
+ assert_equal([], [**kw])
+ assert_equal([h], [**h])
+ assert_equal([{}], [{}])
+ assert_equal([kw], [kw])
+ assert_equal([h], [h])
+
+ assert_equal([1], [1, **{}])
+ assert_equal([1], [1, **kw])
+ assert_equal([1, h], [1, **h])
+ assert_equal([1, {}], [1, {}])
+ assert_equal([1, kw], [1, kw])
+ assert_equal([1, h], [1, h])
+
+ assert_equal([], [**kw, **kw])
+ assert_equal([], [**kw, **{}, **kw])
+ assert_equal([1], [1, **kw, **{}, **kw])
+
+ assert_equal([{}], [{}, **kw, **kw])
+ assert_equal([kw], [kw, **kw, **kw])
+ assert_equal([h], [h, **kw, **kw])
+ assert_equal([h, h], [h, **kw, **kw, **h])
+ end
+
def test_normal_argument
assert_valid_syntax('def foo(x) end')
assert_syntax_error('def foo(X) end', /constant/)