diff --git a/core/kernel/eval_spec.rb b/core/kernel/eval_spec.rb index 59c38c6dee..9be0f2dfd3 100644 --- a/core/kernel/eval_spec.rb +++ b/core/kernel/eval_spec.rb @@ -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 @@ -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