Skip to content

Commit e27cadc

Browse files
committed
[GR-20446] Update Proc#to_s to Ruby 2.7 format
PullRequest: truffleruby/2204
2 parents c48b18a + 536dc58 commit e27cadc

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

spec/ruby/core/proc/shared/to_s.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333

3434
describe "for a proc created with UnboundMethod#to_proc" do
3535
it "returns a description including '(lambda)' and optionally including file and line number" do
36-
def hello; end
37-
method("hello").to_proc.send(@method).should =~ /^#<Proc:([^ ]*?)(#{sep}#{Regexp.escape __FILE__}:#{__LINE__ })? \(lambda\)>$/
36+
def hello; end
37+
s = method("hello").to_proc.send(@method)
38+
if s.include? __FILE__
39+
s.should =~ /^#<Proc:([^ ]*?)#{sep}#{Regexp.escape __FILE__}:#{__LINE__ - 3} \(lambda\)>$/
40+
else
41+
s.should =~ /^#<Proc:([^ ]*?) \(lambda\)>$/
42+
end
3843
end
3944

4045
it "has a binary encoding" do

spec/tags/core/proc/inspect_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

spec/tags/core/proc/to_s_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/ruby/truffleruby/core/proc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def to_s
9393
if sym = Primitive.proc_symbol_to_proc_symbol(self)
9494
suffix << "(&#{sym.inspect})"
9595
elsif file and line
96-
suffix << "@#{file}:#{line}"
96+
suffix << " #{file}:#{line}"
9797
end
9898
suffix << ' (lambda)' if lambda?
9999
base.b.insert(-2, suffix)

0 commit comments

Comments
 (0)