1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-04-28 19:50:06 +00:00
parent b864bd05bf
commit 4fbb9aa3cb
145 changed files with 2847 additions and 2596 deletions

View file

@ -86,16 +86,14 @@ describe "Kernel#define_singleton_method" do
}.should raise_error(ArgumentError)
end
ruby_version_is "2.3" do
it "does not use the caller block when no block is given" do
o = Object.new
def o.define(name)
define_singleton_method(name)
end
lambda {
o.define(:foo) { raise "not used" }
}.should raise_error(ArgumentError)
it "does not use the caller block when no block is given" do
o = Object.new
def o.define(name)
define_singleton_method(name)
end
lambda {
o.define(:foo) { raise "not used" }
}.should raise_error(ArgumentError)
end
end

View file

@ -58,15 +58,13 @@ describe "Kernel.loop" do
lambda{ loop do raise StandardError end }.should raise_error( StandardError )
end
ruby_version_is "2.3" do
it "returns StopIteration#result, the result value of a finished iterator" do
e = Enumerator.new { |y|
y << 1
y << 2
:stopped
}
loop { e.next }.should == :stopped
end
it "returns StopIteration#result, the result value of a finished iterator" do
e = Enumerator.new { |y|
y << 1
y << 2
:stopped
}
loop { e.next }.should == :stopped
end
describe "when no block is given" do

View file

@ -40,6 +40,48 @@ describe "Kernel#require_relative with a relative path" do
ScratchPad.recorded.should == [:loaded]
end
describe "in an #instance_eval with a" do
it "synthetic file base name loads a file base name relative to the working directory" do
Dir.chdir @abs_dir do
Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "foo.rb").should be_true
end
ScratchPad.recorded.should == [:loaded]
end
it "synthetic file path loads a relative path relative to the working directory plus the directory of the synthetic path" do
Dir.chdir @abs_dir do
Object.new.instance_eval("require_relative(File.join('..', #{File.basename(@path).inspect}))", "bar/foo.rb").should be_true
end
ScratchPad.recorded.should == [:loaded]
end
platform_is_not :windows do
it "synthetic relative file path with a Windows path separator specified loads a relative path relative to the working directory" do
Dir.chdir @abs_dir do
Object.new.instance_eval("require_relative(#{File.basename(@path).inspect})", "bar\\foo.rb").should be_true
end
ScratchPad.recorded.should == [:loaded]
end
end
it "absolute file path loads a path relative to the absolute path" do
Object.new.instance_eval("require_relative(#{@path.inspect})", __FILE__).should be_true
ScratchPad.recorded.should == [:loaded]
end
it "absolute file path loads a path relative to the root directory" do
root = @abs_path
until File.dirname(root) == root
root = File.dirname(root)
end
root_relative = @abs_path[root.size..-1]
Object.new.instance_eval("require_relative(#{root_relative.inspect})", "/").should be_true
ScratchPad.recorded.should == [:loaded]
end
end
it "loads a file defining many methods" do
require_relative("#{@dir}/methods_fixture.rb").should be_true
ScratchPad.recorded.should == [:loaded]

View file

@ -454,21 +454,7 @@ describe :kernel_require, shared: true do
ScratchPad.recorded.should == []
end
ruby_version_is "2.2"..."2.3" do
it "complex, enumerator, rational and unicode_normalize are already required" do
provided = %w[complex enumerator rational unicode_normalize]
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
provided.each { |feature|
features.should =~ /\b#{feature}\.(rb|so)$/
}
code = provided.map { |f| "puts require #{f.inspect}\n" }.join
required = ruby_exe(code, options: '--disable-gems')
required.should == "false\n" * provided.size
end
end
ruby_version_is "2.3"..."2.5" do
ruby_version_is ""..."2.5" do
it "complex, enumerator, rational, thread and unicode_normalize are already required" do
provided = %w[complex enumerator rational thread unicode_normalize]
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')