[ruby/prism] Simplify locals test now that all fixtures are valid
https://github.com/ruby/prism/commit/0d32af5719
This commit is contained in:
parent
478b4ef9de
commit
b09604e1fd
@ -30,10 +30,10 @@ if type in 1
|
|||||||
elsif type in B
|
elsif type in B
|
||||||
end
|
end
|
||||||
|
|
||||||
if 1
|
if f1
|
||||||
lambda do |_|
|
lambda do |_|
|
||||||
end
|
end
|
||||||
elsif 2
|
elsif f2
|
||||||
lambda do |_|
|
lambda do |_|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -17,51 +17,11 @@ require_relative "test_helper"
|
|||||||
|
|
||||||
module Prism
|
module Prism
|
||||||
class LocalsTest < TestCase
|
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")
|
base = File.join(__dir__, "fixtures")
|
||||||
skips = invalid | todos
|
|
||||||
|
|
||||||
Dir["**/*.txt", base: base].each do |relative|
|
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)
|
filepath = File.join(base, relative)
|
||||||
define_method("test_#{relative}") { assert_locals(filepath) }
|
define_method("test_#{relative}") { assert_locals(filepath) }
|
||||||
|
@ -391,9 +391,16 @@
|
|||||||
└── @ IfNode (location: (33,0)-(42,3))
|
└── @ IfNode (location: (33,0)-(42,3))
|
||||||
├── if_keyword_loc: (33,0)-(33,2) = "if"
|
├── if_keyword_loc: (33,0)-(33,2) = "if"
|
||||||
├── predicate:
|
├── predicate:
|
||||||
│ @ IntegerNode (location: (33,3)-(33,4))
|
│ @ CallNode (location: (33,3)-(33,5))
|
||||||
│ ├── flags: decimal
|
│ ├── flags: variable_call, ignore_visibility
|
||||||
│ └── value: 1
|
│ ├── receiver: ∅
|
||||||
|
│ ├── call_operator_loc: ∅
|
||||||
|
│ ├── name: :f1
|
||||||
|
│ ├── message_loc: (33,3)-(33,5) = "f1"
|
||||||
|
│ ├── opening_loc: ∅
|
||||||
|
│ ├── arguments: ∅
|
||||||
|
│ ├── closing_loc: ∅
|
||||||
|
│ └── block: ∅
|
||||||
├── then_keyword_loc: ∅
|
├── then_keyword_loc: ∅
|
||||||
├── statements:
|
├── statements:
|
||||||
│ @ StatementsNode (location: (34,2)-(35,5))
|
│ @ StatementsNode (location: (34,2)-(35,5))
|
||||||
@ -434,9 +441,16 @@
|
|||||||
│ @ IfNode (location: (36,0)-(42,3))
|
│ @ IfNode (location: (36,0)-(42,3))
|
||||||
│ ├── if_keyword_loc: (36,0)-(36,5) = "elsif"
|
│ ├── if_keyword_loc: (36,0)-(36,5) = "elsif"
|
||||||
│ ├── predicate:
|
│ ├── predicate:
|
||||||
│ │ @ IntegerNode (location: (36,6)-(36,7))
|
│ │ @ CallNode (location: (36,6)-(36,8))
|
||||||
│ │ ├── flags: decimal
|
│ │ ├── flags: variable_call, ignore_visibility
|
||||||
│ │ └── value: 2
|
│ │ ├── receiver: ∅
|
||||||
|
│ │ ├── call_operator_loc: ∅
|
||||||
|
│ │ ├── name: :f2
|
||||||
|
│ │ ├── message_loc: (36,6)-(36,8) = "f2"
|
||||||
|
│ │ ├── opening_loc: ∅
|
||||||
|
│ │ ├── arguments: ∅
|
||||||
|
│ │ ├── closing_loc: ∅
|
||||||
|
│ │ └── block: ∅
|
||||||
│ ├── then_keyword_loc: ∅
|
│ ├── then_keyword_loc: ∅
|
||||||
│ ├── statements:
|
│ ├── statements:
|
||||||
│ │ @ StatementsNode (location: (37,2)-(38,5))
|
│ │ @ StatementsNode (location: (37,2)-(38,5))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user