aboutsummaryrefslogtreecommitdiffstats
path: root/test/ripper
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-08 06:00:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-08 06:00:57 +0000
commit99fd3ceeaea2b816858d07e30dd4446683502135 (patch)
treef95618cadb1fb1a07bf33f33e681cda1f8650870 /test/ripper
parent7f5c82092bb9fdd0442277099cef4bcc35eb2044 (diff)
downloadruby-99fd3ceeaea2b816858d07e30dd4446683502135.tar.gz
parse.y: fix a typo
* parse.y (f_kw): fix typo. needs the argument value, not the label twice. [ruby-core:83174] [Bug #13987] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_sexp.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ripper/test_sexp.rb b/test/ripper/test_sexp.rb
index 253b198442..064c0f1536 100644
--- a/test/ripper/test_sexp.rb
+++ b/test/ripper/test_sexp.rb
@@ -96,6 +96,20 @@ eot
assert_equal("t", fname)
end
+ def test_named_with_default
+ sexp = Ripper.sexp("def hello(bln: true, int: 1, str: 'str', sym: :sym) end")
+ named = String.new
+ search_sexp(:params, sexp)[5].each { |i| named << "#{i}\n" } # join flattens
+ exp = "#{<<-"{#"}#{<<~'};'}"
+ {#
+ [[:@label, "bln:", [1, 10]], [:var_ref, [:@kw, "true", [1, 15]]]]
+ [[:@label, "int:", [1, 21]], [:@int, "1", [1, 26]]]
+ [[:@label, "str:", [1, 29]], [:string_literal, [:string_content, [:@tstring_content, "str", [1, 35]]]]]
+ [[:@label, "sym:", [1, 41]], [:symbol_literal, [:symbol, [:@ident, "sym", [1, 47]]]]]
+ };
+ assert_equal(exp, named)
+ end
+
def search_sexp(sym, sexp)
return sexp if !sexp or sexp[0] == sym
sexp.find do |e|