diff options
Diffstat (limited to 'spec/ruby/core/kernel')
| -rw-r--r-- | spec/ruby/core/kernel/Integer_spec.rb | 17 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/caller_spec.rb | 17 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/eval_spec.rb | 40 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/lambda_spec.rb | 52 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/open_spec.rb | 14 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/shared/require.rb | 16 | ||||
| -rw-r--r-- | spec/ruby/core/kernel/sleep_spec.rb | 28 |
7 files changed, 54 insertions, 130 deletions
diff --git a/spec/ruby/core/kernel/Integer_spec.rb b/spec/ruby/core/kernel/Integer_spec.rb index 74dd3e0dd2..c62b8b0801 100644 --- a/spec/ruby/core/kernel/Integer_spec.rb +++ b/spec/ruby/core/kernel/Integer_spec.rb @@ -586,19 +586,10 @@ describe :kernel_integer_string_base, shared: true do Integer("777", obj).should == 0777 end - # https://bugs.ruby-lang.org/issues/19349 - ruby_version_is ''...'3.3' do - it "ignores the base if it is not an integer and does not respond to #to_i" do - Integer("777", "8").should == 777 - end - end - - ruby_version_is '3.3' do - it "raises a TypeError if it is not an integer and does not respond to #to_i" do - -> { - Integer("777", "8") - }.should raise_error(TypeError, "no implicit conversion of String into Integer") - end + it "raises a TypeError if it is not an integer and does not respond to #to_i" do + -> { + Integer("777", "8") + }.should raise_error(TypeError, "no implicit conversion of String into Integer") end describe "when passed exception: false" do diff --git a/spec/ruby/core/kernel/caller_spec.rb b/spec/ruby/core/kernel/caller_spec.rb index 7cd703de5a..df051ef07f 100644 --- a/spec/ruby/core/kernel/caller_spec.rb +++ b/spec/ruby/core/kernel/caller_spec.rb @@ -84,14 +84,25 @@ describe 'Kernel#caller' do end guard -> { Kernel.instance_method(:tap).source_location } do - ruby_version_is ""..."4.0" do + ruby_version_is ""..."3.4" do it "includes core library methods defined in Ruby" do file, line = Kernel.instance_method(:tap).source_location file.should.start_with?('<internal:') loc = nil tap { loc = caller(1, 1)[0] } - loc.should =~ /\A<internal:.*in [`'](?:Kernel#)?tap'\z/ + loc.should =~ /\A<internal:.*in `tap'\z/ + end + end + + ruby_version_is "3.4"..."4.0" do + it "includes core library methods defined in Ruby" do + file, line = Kernel.instance_method(:tap).source_location + file.should.start_with?('<internal:') + + loc = nil + tap { loc = caller(1, 1)[0] } + loc.should =~ /\A<internal:.*in 'Kernel#tap'\z/ end end @@ -102,7 +113,7 @@ describe 'Kernel#caller' do loc = nil tap { loc = caller(1, 1)[0] } - loc.should =~ /\A#{ __FILE__ }:.*in [`'](?:Kernel#)?tap'\z/ + loc.should =~ /\A#{__FILE__}:.*in 'Kernel#tap'\z/ end end end diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb index e027294347..c1136efd69 100644 --- a/spec/ruby/core/kernel/eval_spec.rb +++ b/spec/ruby/core/kernel/eval_spec.rb @@ -159,22 +159,6 @@ describe "Kernel#eval" do end end - ruby_version_is ""..."3.3" do - it "uses (eval) filename if none is provided" do - eval("__FILE__").should == "(eval)" - eval("__FILE__", binding).should == "(eval)" - eval("__FILE__", binding, "success").should == "success" - eval("eval '__FILE__', binding").should == "(eval)" - eval("eval '__FILE__', binding", binding).should == "(eval)" - 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 - context "parameter forwarding" do it "allows anonymous rest parameter forwarding" do object = Object.new @@ -244,20 +228,18 @@ describe "Kernel#eval" do end end - ruby_version_is "3.3" do - it "uses (eval at __FILE__:__LINE__) if none is provided" do - eval("__FILE__").should == "(eval at #{__FILE__}:#{__LINE__})" - eval("__FILE__", binding).should == "(eval at #{__FILE__}:#{__LINE__})" - eval("__FILE__", binding, "success").should == "success" - eval("eval '__FILE__', binding").should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)" - eval("eval '__FILE__', binding", binding).should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)" - eval("eval '__FILE__', binding", binding, 'success').should == "(eval at success:1)" - eval("eval '__FILE__', binding, 'success'", binding).should == 'success' - end + it "uses (eval at __FILE__:__LINE__) if none is provided" do + eval("__FILE__").should == "(eval at #{__FILE__}:#{__LINE__})" + eval("__FILE__", binding).should == "(eval at #{__FILE__}:#{__LINE__})" + eval("__FILE__", binding, "success").should == "success" + eval("eval '__FILE__', binding").should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)" + eval("eval '__FILE__', binding", binding).should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)" + eval("eval '__FILE__', binding", binding, 'success').should == "(eval at success:1)" + eval("eval '__FILE__', binding, 'success'", binding).should == 'success' + end - it 'uses (eval at __FILE__:__LINE__) for __FILE__ and 1 for __LINE__ with a binding argument' do - eval("[__FILE__, __LINE__]", binding).should == ["(eval at #{__FILE__}:#{__LINE__})", 1] - end + it 'uses (eval at __FILE__:__LINE__) for __FILE__ and 1 for __LINE__ with a binding argument' do + eval("[__FILE__, __LINE__]", binding).should == ["(eval at #{__FILE__}:#{__LINE__})", 1] end # Found via Rubinius bug github:#149 it "does not alter the value of __FILE__ in the binding" do diff --git a/spec/ruby/core/kernel/lambda_spec.rb b/spec/ruby/core/kernel/lambda_spec.rb index 565536ac0d..fa0e17b748 100644 --- a/spec/ruby/core/kernel/lambda_spec.rb +++ b/spec/ruby/core/kernel/lambda_spec.rb @@ -26,46 +26,6 @@ describe "Kernel.lambda" do l.lambda?.should be_true end - ruby_version_is ""..."3.3" do - it "creates a lambda-style Proc if given a literal block via Kernel.public_send" do - suppress_warning do - l = Kernel.public_send(:lambda) { 42 } - l.lambda?.should be_true - end - end - - it "returns the passed Proc if given an existing Proc" do - some_proc = proc {} - l = suppress_warning {lambda(&some_proc)} - l.should equal(some_proc) - l.lambda?.should be_false - end - - it "creates a lambda-style Proc when called with zsuper" do - suppress_warning do - l = KernelSpecs::LambdaSpecs::ForwardBlockWithZSuper.new.lambda { 42 } - l.lambda?.should be_true - l.call.should == 42 - - lambda { l.call(:extra) }.should raise_error(ArgumentError) - end - end - - it "returns the passed Proc if given an existing Proc through super" do - some_proc = proc { } - l = KernelSpecs::LambdaSpecs::SuperAmpersand.new.lambda(&some_proc) - l.should equal(some_proc) - l.lambda?.should be_false - end - - it "does not create lambda-style Procs when captured with #method" do - kernel_lambda = method(:lambda) - l = suppress_warning {kernel_lambda.call { 42 }} - l.lambda?.should be_false - l.call(:extra).should == 42 - end - end - it "checks the arity of the call when no args are specified" do l = lambda { :called } l.call.should == :called @@ -139,16 +99,8 @@ describe "Kernel.lambda" do end context "when called without a literal block" do - ruby_version_is ""..."3.3" do - it "warns when proc isn't a lambda" do - -> { lambda(&proc{}) }.should complain("#{__FILE__}:#{__LINE__}: warning: lambda without a literal block is deprecated; use the proc without lambda instead\n") - end - end - - ruby_version_is "3.3" do - it "raises when proc isn't a lambda" do - -> { lambda(&proc{}) }.should raise_error(ArgumentError, /the lambda method requires a literal block/) - end + it "raises when proc isn't a lambda" do + -> { lambda(&proc{}) }.should raise_error(ArgumentError, /the lambda method requires a literal block/) end it "doesn't warn when proc is lambda" do diff --git a/spec/ruby/core/kernel/open_spec.rb b/spec/ruby/core/kernel/open_spec.rb index b967d5044b..9d3f3760b9 100644 --- a/spec/ruby/core/kernel/open_spec.rb +++ b/spec/ruby/core/kernel/open_spec.rb @@ -79,14 +79,12 @@ describe "Kernel#open" do end end - ruby_version_is "3.3" do - # https://bugs.ruby-lang.org/issues/19630 - it "warns about deprecation given a path with a pipe" do - cmd = "|echo ok" - -> { - open(cmd) { |f| f.read } - }.should complain(/Kernel#open with a leading '\|'/) - end + # https://bugs.ruby-lang.org/issues/19630 + it "warns about deprecation given a path with a pipe" do + cmd = "|echo ok" + -> { + open(cmd) { |f| f.read } + }.should complain(/Kernel#open with a leading '\|'/) end end diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb index 52f86f73e5..ef5b9486c6 100644 --- a/spec/ruby/core/kernel/shared/require.rb +++ b/spec/ruby/core/kernel/shared/require.rb @@ -266,15 +266,13 @@ describe :kernel_require, shared: true do ScratchPad.recorded.should == [:loaded] end - ruby_bug "#17340", ''...'3.3' do - it "loads a file concurrently" do - path = File.expand_path "concurrent_require_fixture.rb", CODE_LOADING_DIR - ScratchPad.record(@object) - -> { - @object.require(path) - }.should_not complain(/circular require considered harmful/, verbose: true) - ScratchPad.recorded.join - end + it "loads a file concurrently" do + path = File.expand_path "concurrent_require_fixture.rb", CODE_LOADING_DIR + ScratchPad.record(@object) + -> { + @object.require(path) + }.should_not complain(/circular require considered harmful/, verbose: true) + ScratchPad.recorded.join end end diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb index e9c600aac4..0b003ad189 100644 --- a/spec/ruby/core/kernel/sleep_spec.rb +++ b/spec/ruby/core/kernel/sleep_spec.rb @@ -63,27 +63,19 @@ describe "Kernel#sleep" do actual_duration.should > 0.01 # 100 * 0.0001 => 0.01 end - ruby_version_is ""..."3.3" do - it "raises a TypeError when passed nil" do - -> { sleep(nil) }.should raise_error(TypeError) + it "accepts a nil duration" do + running = false + t = Thread.new do + running = true + sleep(nil) + 5 end - end - - ruby_version_is "3.3" do - it "accepts a nil duration" do - running = false - t = Thread.new do - running = true - sleep(nil) - 5 - end - Thread.pass until running - Thread.pass while t.status and t.status != "sleep" + Thread.pass until running + Thread.pass while t.status and t.status != "sleep" - t.wakeup - t.value.should == 5 - end + t.wakeup + t.value.should == 5 end context "Kernel.sleep with Fiber scheduler" do |
