Skip to content

Commit

Permalink
Fix eval with Binding __FILE__/__LINE__ spec
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Oct 16, 2021
1 parent 54e4631 commit 8ba758c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/kernel/eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ class Object
suppress_warning {eval("eval '__FILE__', binding", binding)}.should == __FILE__
suppress_warning {eval("eval '__FILE__', binding", binding, 'success')}.should == 'success'
end

it 'uses the given binding file and line for __FILE__ and __LINE__' do
suppress_warning {
eval("[__FILE__, __LINE__]", binding).should == [__FILE__, __LINE__]
}
end
end

ruby_version_is "3.0" do
Expand All @@ -180,15 +186,9 @@ class Object
eval("eval '__FILE__', binding", binding, 'success').should == '(eval)'
eval("eval '__FILE__', binding, 'success'", binding).should == 'success'
end
end

ruby_version_is "3.0" do
context 'with two arguments ' do
platform_is_not :windows do
it 'will use (eval) for __FILE__ and 1 for __LINE__' do
eval("p [__FILE__, __LINE__]", binding).should == ["(eval)", 1]
end
end
it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do
eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1]
end
end

Expand Down

0 comments on commit 8ba758c

Please sign in to comment.