From b09604e1fd5768daf31aaa4f8130fa8cd9b8d240 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 3 Apr 2024 14:36:56 -0400 Subject: [PATCH] [ruby/prism] Simplify locals test now that all fixtures are valid https://github.com/ruby/prism/commit/0d32af5719 --- test/prism/fixtures/if.txt | 4 ++-- test/prism/locals_test.rb | 46 +++---------------------------------- test/prism/snapshots/if.txt | 26 ++++++++++++++++----- 3 files changed, 25 insertions(+), 51 deletions(-) diff --git a/test/prism/fixtures/if.txt b/test/prism/fixtures/if.txt index cede644a4c2149..4139bae5edbbd2 100644 --- a/test/prism/fixtures/if.txt +++ b/test/prism/fixtures/if.txt @@ -30,10 +30,10 @@ if type in 1 elsif type in B end -if 1 +if f1 lambda do |_| end -elsif 2 +elsif f2 lambda do |_| end else diff --git a/test/prism/locals_test.rb b/test/prism/locals_test.rb index 1453e7aecddedd..0eb73f1b9c76b0 100644 --- a/test/prism/locals_test.rb +++ b/test/prism/locals_test.rb @@ -17,51 +17,11 @@ module Prism class LocalsTest < TestCase - invalid = [] - todos = [] - - # Invalid break - invalid << "break.txt" - invalid << "if.txt" - invalid << "rescue.txt" - invalid << "seattlerb/block_break.txt" - invalid << "unless.txt" - invalid << "whitequark/break.txt" - invalid << "whitequark/break_block.txt" - - # Invalid next - invalid << "next.txt" - invalid << "seattlerb/block_next.txt" - invalid << "unparser/corpus/literal/control.txt" - invalid << "whitequark/next.txt" - invalid << "whitequark/next_block.txt" - - # Invalid redo - invalid << "keywords.txt" - invalid << "whitequark/redo.txt" - - # Invalid retry - invalid << "whitequark/retry.txt" - - # Invalid yield - invalid << "seattlerb/dasgn_icky2.txt" - invalid << "seattlerb/yield_arg.txt" - invalid << "seattlerb/yield_call_assocs.txt" - invalid << "seattlerb/yield_empty_parens.txt" - invalid << "unparser/corpus/literal/yield.txt" - invalid << "whitequark/args_assocs.txt" - invalid << "whitequark/args_assocs_legacy.txt" - invalid << "whitequark/yield.txt" - invalid << "yield.txt" - - # Dead code eliminated - invalid << "whitequark/ruby_bug_10653.txt" - base = File.join(__dir__, "fixtures") - skips = invalid | todos - Dir["**/*.txt", base: base].each do |relative| - next if skips.include?(relative) + # Skip this fixture because it has a different number of locals because + # CRuby is eliminating dead code. + next if relative == "whitequark/ruby_bug_10653.txt" filepath = File.join(base, relative) define_method("test_#{relative}") { assert_locals(filepath) } diff --git a/test/prism/snapshots/if.txt b/test/prism/snapshots/if.txt index b618659756a215..eb33d1699d55f8 100644 --- a/test/prism/snapshots/if.txt +++ b/test/prism/snapshots/if.txt @@ -391,9 +391,16 @@ └── @ IfNode (location: (33,0)-(42,3)) ├── if_keyword_loc: (33,0)-(33,2) = "if" ├── predicate: - │ @ IntegerNode (location: (33,3)-(33,4)) - │ ├── flags: decimal - │ └── value: 1 + │ @ CallNode (location: (33,3)-(33,5)) + │ ├── flags: variable_call, ignore_visibility + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── name: :f1 + │ ├── message_loc: (33,3)-(33,5) = "f1" + │ ├── opening_loc: ∅ + │ ├── arguments: ∅ + │ ├── closing_loc: ∅ + │ └── block: ∅ ├── then_keyword_loc: ∅ ├── statements: │ @ StatementsNode (location: (34,2)-(35,5)) @@ -434,9 +441,16 @@ │ @ IfNode (location: (36,0)-(42,3)) │ ├── if_keyword_loc: (36,0)-(36,5) = "elsif" │ ├── predicate: - │ │ @ IntegerNode (location: (36,6)-(36,7)) - │ │ ├── flags: decimal - │ │ └── value: 2 + │ │ @ CallNode (location: (36,6)-(36,8)) + │ │ ├── flags: variable_call, ignore_visibility + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :f2 + │ │ ├── message_loc: (36,6)-(36,8) = "f2" + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ └── block: ∅ │ ├── then_keyword_loc: ∅ │ ├── statements: │ │ @ StatementsNode (location: (37,2)-(38,5))