Skip to content

Commit edf78cd

Browse files
andrykonchineregon
authored andcommitted
Fix issue with quarantined specs for #syntax_tree
1 parent 9c936cf commit edf78cd

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

‎core/proc/fixtures/syntax_tree.rb‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Avoids warnings on Ruby 3.3
2+
module ProcSpecs
3+
module SyntaxTree
4+
def self.lambda_it
5+
-> { it }
6+
end
7+
LAMBDA_IT_LINE = __LINE__ - 2
8+
9+
def self.proc_it
10+
proc { it }
11+
end
12+
PROC_IT_LINE = __LINE__ - 2
13+
end
14+
end

‎core/proc/syntax_tree_spec.rb‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
require_relative '../../fixtures/source_range_helpers'
33

44
ruby_version_is "4.1" do
5+
require_relative 'fixtures/syntax_tree' # avoids warnings on Ruby 3.3
6+
57
describe "Proc#syntax_tree" do
68
before :each do
79
skip "parse.y" unless syntax_tree_returns_prism_node
@@ -38,26 +40,24 @@ def return_block(&b)
3840
node.should.is_a?(Ruby::Prism::LambdaNode)
3941
end
4042

41-
quarantine! do # NoMethodError: undefined method 'start_line' for nil
4243
it "does not return implicit parameter nodes" do
4344
# Interesting because the BlockNode and the ItParametersNode/NumberedParametersNode are fully overlapping
44-
node = eval('-> { it }.syntax_tree') # emits a warning on Ruby 3.3
45-
node.start_line.should == __LINE__ - 1
45+
node = ProcSpecs::SyntaxTree.lambda_it.syntax_tree
46+
node.start_line.should == ProcSpecs::SyntaxTree::LAMBDA_IT_LINE
4647
node.should.is_a?(Ruby::Prism::LambdaNode)
4748

4849
node = -> { _1 }.syntax_tree
4950
node.start_line.should == __LINE__ - 1
5051
node.should.is_a?(Ruby::Prism::LambdaNode)
5152

52-
node = eval('proc { it }.syntax_tree') # emits a warning on Ruby 3.3
53-
node.start_line.should == __LINE__ - 1
53+
node = ProcSpecs::SyntaxTree.proc_it.syntax_tree
54+
node.start_line.should == ProcSpecs::SyntaxTree::PROC_IT_LINE
5455
node.should.is_a?(Ruby::Prism::CallNode)
5556

5657
node = proc { _1 }.syntax_tree
5758
node.start_line.should == __LINE__ - 1
5859
node.should.is_a?(Ruby::Prism::CallNode)
5960
end
60-
end
6161

6262
it "returns a ForNode for a for-loop block" do
6363
iter = Object.new

0 commit comments

Comments
 (0)