Skip to content

Commit

Permalink
[ruby/prism] Fix up case consequent in ripper translation
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Mar 6, 2024
1 parent f4d1a36 commit ff9df28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/prism/translation/ripper.rb
Expand Up @@ -804,7 +804,7 @@ def visit_capture_pattern_node(node)
def visit_case_node(node)
predicate = visit(node.predicate)
clauses =
node.conditions.reverse_each.inject(nil) do |consequent, condition|
node.conditions.reverse_each.inject(visit(node.consequent)) do |consequent, condition|
on_when(*visit(condition), consequent)
end

Expand All @@ -817,7 +817,7 @@ def visit_case_node(node)
def visit_case_match_node(node)
predicate = visit(node.predicate)
clauses =
node.conditions.reverse_each.inject(nil) do |consequent, condition|
node.conditions.reverse_each.inject(visit(node.consequent)) do |consequent, condition|
on_in(*visit(condition), consequent)
end

Expand Down
19 changes: 7 additions & 12 deletions test/prism/ripper_test.rb
Expand Up @@ -10,7 +10,13 @@ class RipperTest < TestCase
base = File.join(__dir__, "fixtures")
relatives = ENV["FOCUS"] ? [ENV["FOCUS"]] : Dir["**/*.txt", base: base]

skips = %w[
failures = %w[
whitequark/break_block.txt
whitequark/next_block.txt
whitequark/return_block.txt
]

skips = failures | %w[
arrays.txt
blocks.txt
case.txt
Expand Down Expand Up @@ -55,7 +61,6 @@ class RipperTest < TestCase
seattlerb/call_block_arg_named.txt
seattlerb/call_trailing_comma.txt
seattlerb/case_in.txt
seattlerb/case_in_else.txt
seattlerb/class_comments.txt
seattlerb/defn_oneliner_eq2.txt
seattlerb/defn_oneliner_rescue.txt
Expand Down Expand Up @@ -131,7 +136,6 @@ class RipperTest < TestCase
unless.txt
unparser/corpus/literal/assignment.txt
unparser/corpus/literal/block.txt
unparser/corpus/literal/case.txt
unparser/corpus/literal/class.txt
unparser/corpus/literal/def.txt
unparser/corpus/literal/dstr.txt
Expand Down Expand Up @@ -166,18 +170,13 @@ class RipperTest < TestCase
whitequark/args_cmd.txt
whitequark/args_star.txt
whitequark/asgn_mrhs.txt
whitequark/break_block.txt
whitequark/bug_480.txt
whitequark/case_cond_else.txt
whitequark/case_expr_else.txt
whitequark/dedenting_heredoc.txt
whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt
whitequark/dedenting_non_interpolating_heredoc_line_continuation.txt
whitequark/def.txt
whitequark/empty_stmt.txt
whitequark/forward_args_legacy.txt
whitequark/forwarded_kwrestarg_with_additional_kwarg.txt
whitequark/forwarded_restarg.txt
whitequark/if_elsif.txt
whitequark/kwbegin_compstmt.txt
whitequark/lvar_injecting_match.txt
Expand All @@ -186,15 +185,11 @@ class RipperTest < TestCase
whitequark/masgn_nested.txt
whitequark/masgn_splat.txt
whitequark/newline_in_hash_argument.txt
whitequark/next_block.txt
whitequark/numbered_args_after_27.txt
whitequark/parser_bug_640.txt
whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt
whitequark/parser_slash_slash_n_escaping_in_literals.txt
whitequark/pattern_matching_blank_else.txt
whitequark/pattern_matching_else.txt
whitequark/rescue_without_begin_end.txt
whitequark/return_block.txt
whitequark/ruby_bug_11107.txt
whitequark/ruby_bug_11873.txt
whitequark/ruby_bug_11873_a.txt
Expand Down

0 comments on commit ff9df28

Please sign in to comment.