diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-05-29 10:12:51 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-05-30 15:18:20 -0400 |
| commit | 72452f43871b8034bfa718ed823bc62b5b81d6f9 (patch) | |
| tree | 1bd87295dfcf10d20bce7f6d18184644bb079387 /lib | |
| parent | 1ab7c412d2e3880a7ad233c32e93961888f8145c (diff) | |
[ruby/prism] Tests overhaul
https://github.com/ruby/prism/commit/6f886be0a4
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/ffi.rb | 25 | ||||
| -rw-r--r-- | lib/prism/translation/ruby_parser.rb | 4 |
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index df7e183310..6b48af43cc 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -200,8 +200,8 @@ module Prism class << self # Mirror the Prism.dump API by using the serialization API. - def dump(code, **options) - LibRubyParser::PrismString.with_string(code) { |string| dump_common(string, options) } + def dump(source, **options) + LibRubyParser::PrismString.with_string(source) { |string| dump_common(string, options) } end # Mirror the Prism.dump_file API by using the serialization API. @@ -302,6 +302,27 @@ module Prism !parse_file_success?(filepath, **options) end + # Mirror the Prism.profile API by using the serialization API. + def profile(source, **options) + LibRubyParser::PrismString.with_string(source) do |string| + LibRubyParser::PrismBuffer.with do |buffer| + LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options)) + nil + end + end + end + + # Mirror the Prism.profile_file API by using the serialization API. + def profile_file(filepath, **options) + LibRubyParser::PrismString.with_file(filepath) do |string| + LibRubyParser::PrismBuffer.with do |buffer| + options[:filepath] = filepath + LibRubyParser.pm_serialize_parse(buffer.pointer, string.pointer, string.length, dump_options(options)) + nil + end + end + end + private def dump_common(string, options) # :nodoc: diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index ec458a3b63..38690c54b3 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -485,9 +485,9 @@ module Prism def visit_constant_path_target_node(node) inner = if node.parent.nil? - s(node, :colon3, node.child.name) + s(node, :colon3, node.name) else - s(node, :colon2, visit(node.parent), node.child.name) + s(node, :colon2, visit(node.parent), node.name) end s(node, :const, inner) |
