summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-04-03 14:36:56 -0400
committergit <svn-admin@ruby-lang.org>2024-04-08 16:54:25 +0000
commitb09604e1fd5768daf31aaa4f8130fa8cd9b8d240 (patch)
tree10b5c26710e9ebd3216115e4f2a78ae40d413f48
parent478b4ef9de0de0d087f5c8d4d94b0b4af3753c6f (diff)
[ruby/prism] Simplify locals test now that all fixtures are valid
https://github.com/ruby/prism/commit/0d32af5719
-rw-r--r--test/prism/fixtures/if.txt4
-rw-r--r--test/prism/locals_test.rb46
-rw-r--r--test/prism/snapshots/if.txt26
3 files changed, 25 insertions, 51 deletions
diff --git a/test/prism/fixtures/if.txt b/test/prism/fixtures/if.txt
index cede644a4c..4139bae5ed 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 1453e7aecd..0eb73f1b9c 100644
--- a/test/prism/locals_test.rb
+++ b/test/prism/locals_test.rb
@@ -17,51 +17,11 @@ require_relative "test_helper"
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 b618659756..eb33d1699d 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))