diff --git a/core/kernel/eval_spec.rb b/core/kernel/eval_spec.rb index 1e2764a4de..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,6 +186,10 @@ class Object eval("eval '__FILE__', binding", binding, 'success').should == '(eval)' eval("eval '__FILE__', binding, 'success'", binding).should == 'success' end + + it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do + eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1] + end end # Found via Rubinius bug github:#149 diff --git a/library/socket/tcpsocket/shared/new.rb b/library/socket/tcpsocket/shared/new.rb index 30e963b12a..4189acc2f8 100644 --- a/library/socket/tcpsocket/shared/new.rb +++ b/library/socket/tcpsocket/shared/new.rb @@ -14,10 +14,12 @@ } end - it 'raises Errno::ETIMEDOUT with :connect_timeout when no server is listening on the given address' do - -> { - TCPSocket.send(@method, "192.0.2.1", 80, connect_timeout: 0) - }.should raise_error(Errno::ETIMEDOUT) + ruby_version_is "3.0" do + it 'raises Errno::ETIMEDOUT with :connect_timeout when no server is listening on the given address' do + -> { + TCPSocket.send(@method, "192.0.2.1", 80, connect_timeout: 0) + }.should raise_error(Errno::ETIMEDOUT) + end end describe "with a running server" do