Skip to content

Commit fcece03

Browse files
committed
Move out the inline method definition for Ruby 2.7
1 parent 5d510f5 commit fcece03

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

test/prism/ruby/inline_method.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# A separate file because 2.7 can't parse this
2+
module Prism
3+
class NodeForTest < TestCase
4+
def inline_method = 42
5+
INLINE_LOCATION_AND_FILE = [[__LINE__-1, 4, __LINE__-1, 26], __FILE__]
6+
end
7+
end

test/prism/ruby/node_for_test.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# Needs Prism.parse_file(file, version: "current")
77
return if RUBY_VERSION < "3.3"
88

9+
require_relative 'inline_method'
10+
911
module Prism
1012
class NodeForTest < TestCase
1113
INDENT = ' ' * 4
@@ -15,9 +17,6 @@ def m(foo)
1517
end
1618
M_LOCATION = [__LINE__-3, 4, __LINE__-1, 7]
1719

18-
def inline_method = 42
19-
INLINE_LOCATION = [__LINE__-1, 4, __LINE__-1, 26]
20-
2120
define_method(:define_method_method) { 42 }
2221
DEFINE_METHOD_LOCATION = [__LINE__-1, 41, __LINE__-1, 47]
2322

@@ -44,7 +43,7 @@ def test_def_method
4443
end
4544

4645
def test_inline_method
47-
node = Prism.node_for(with_location(method(:inline_method), INLINE_LOCATION))
46+
node = Prism.node_for(with_location(method(:inline_method), *INLINE_LOCATION_AND_FILE))
4847
assert_instance_of(Prism::DefNode, node)
4948
assert_equal "def inline_method = 42", node.slice
5049
end
@@ -89,7 +88,7 @@ def test_proc
8988
end
9089

9190
def test_method_to_proc
92-
node = Prism.node_for(with_location(method(:inline_method).to_proc, INLINE_LOCATION))
91+
node = Prism.node_for(with_location(method(:inline_method).to_proc, *INLINE_LOCATION_AND_FILE))
9392
assert_instance_of(Prism::DefNode, node)
9493
assert_equal "def inline_method = 42", node.slice
9594
end

0 commit comments

Comments
 (0)