summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-09-09 19:33:29 +0900
committernagachika <nagachika@ruby-lang.org>2023-09-09 19:33:29 +0900
commitbb877e5b4fe81965af60a0d86daeb8ed477e8e87 (patch)
treeb85cf46b8567773d99fadc1025ca399f9ec9ca50 /test
parent0b7a4fbaa9c56d2c67d00d86c69f9e5c71803267 (diff)
merge revision(s) 382678d4112f4afc6272244c22924d2b004274b1: [Backport #19788]
[Bug #19788] Use the result of `tCOLON2` event --- parse.y | 16 ++++++++-------- test/ripper/test_parser_events.rb | 17 +++++++++++++++++ test/ripper/test_scanner_events.rb | 5 +++++ 3 files changed, 30 insertions(+), 8 deletions(-)
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_parser_events.rb17
-rw-r--r--test/ripper/test_scanner_events.rb5
2 files changed, 22 insertions, 0 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 1ea8d23378..c4d9a627a6 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -499,6 +499,23 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal "[call(ref(self),&.,foo,[])]", tree
end
+ def test_call_colon2
+ hook = Module.new do
+ def on_op(op)
+ super("(op: #{op.inspect})")
+ end
+ def on_call(recv, name, *args)
+ super(recv, "(method: #{name})", *args)
+ end
+ def on_ident(name)
+ super("(ident: #{name.inspect})")
+ end
+ end
+
+ parser = DummyParser.new("a::b").extend(hook)
+ assert_equal '[call(vcall((ident: "a")),(method: (op: "::")),(ident: "b"))]', parser.parse.to_s
+ end
+
def test_excessed_comma
thru_excessed_comma = false
parse("proc{|x,|}", :on_excessed_comma) {thru_excessed_comma = true}
diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb
index 13bd44e83d..f75c61765c 100644
--- a/test/ripper/test_scanner_events.rb
+++ b/test/ripper/test_scanner_events.rb
@@ -179,6 +179,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('backtick', %q[p `make all`])
end
+ def test_colon2_call
+ assert_equal ["::"],
+ scan('op', %q[ a::b ])
+ end
+
def test_comma
assert_equal [','] * 6,
scan('comma', %q[ m(0,1,2,3,4,5,6) ])