mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@a585ec3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6c2b589865
commit
9245e097ec
7 changed files with 108 additions and 64 deletions
|
@ -122,6 +122,18 @@ describe "Dir.glob" do
|
|||
Dir.glob('**/**/**').empty?.should == false
|
||||
end
|
||||
|
||||
it "handles simple filename patterns" do
|
||||
Dir.glob('.dotfile').should == ['.dotfile']
|
||||
end
|
||||
|
||||
it "handles simple directory patterns" do
|
||||
Dir.glob('.dotsubdir/').should == ['.dotsubdir/']
|
||||
end
|
||||
|
||||
it "handles simple directory patterns applied to non-directories" do
|
||||
Dir.glob('nondotfile/').should == []
|
||||
end
|
||||
|
||||
platform_is_not(:windows) do
|
||||
it "matches the literal character '\\' with option File::FNM_NOESCAPE" do
|
||||
Dir.mkdir 'foo?bar'
|
||||
|
|
|
@ -13,9 +13,11 @@ ruby_version_is '2.4' do
|
|||
@lazy.force.should == [0, 1]
|
||||
end
|
||||
|
||||
it 'return same value after rewind' do
|
||||
@lazy.force.should == [0, 1]
|
||||
@lazy.force.should == [0, 1]
|
||||
ruby_bug "#14495", "2.4"..."2.5.1" do
|
||||
it 'return same value after rewind' do
|
||||
@lazy.force.should == [0, 1]
|
||||
@lazy.force.should == [0, 1]
|
||||
end
|
||||
end
|
||||
|
||||
it 'sets the size to nil' do
|
||||
|
@ -33,9 +35,11 @@ ruby_version_is '2.4' do
|
|||
@lazy.force.should == [0, 1]
|
||||
end
|
||||
|
||||
it 'return same value after rewind' do
|
||||
@lazy.force.should == [0, 1]
|
||||
@lazy.force.should == [0, 1]
|
||||
ruby_bug "#14495", "2.4"..."2.5.1" do
|
||||
it 'return same value after rewind' do
|
||||
@lazy.force.should == [0, 1]
|
||||
@lazy.force.should == [0, 1]
|
||||
end
|
||||
end
|
||||
|
||||
it 'sets the size to nil' do
|
||||
|
@ -56,10 +60,12 @@ ruby_version_is '2.4' do
|
|||
@lazy = enum.lazy
|
||||
end
|
||||
|
||||
it 'return same value after rewind' do
|
||||
enum = @lazy.uniq { |_, label| label.downcase }
|
||||
enum.force.should == [[0, 'foo'], [2, 'bar']]
|
||||
enum.force.should == [[0, 'foo'], [2, 'bar']]
|
||||
ruby_bug "#14495", "2.4"..."2.5.1" do
|
||||
it 'return same value after rewind' do
|
||||
enum = @lazy.uniq { |_, label| label.downcase }
|
||||
enum.force.should == [[0, 'foo'], [2, 'bar']]
|
||||
enum.force.should == [[0, 'foo'], [2, 'bar']]
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns all yield arguments as an array' do
|
||||
|
|
|
@ -61,21 +61,21 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
|
||||
# https://bugs.ruby-lang.org/issues/14380
|
||||
ruby_version_is ""..."2.6" do
|
||||
ruby_version_is ""..."2.5.1" do
|
||||
it "does not prevent conflicts between new keys and old ones" do
|
||||
@hash.transform_keys!(&:succ)
|
||||
@hash.should == { e: 1 }
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
ruby_version_is "2.5.1" do
|
||||
it "prevents conflicts between new keys and old ones" do
|
||||
@hash.transform_keys!(&:succ)
|
||||
@hash.should == { b: 1, c: 2, d: 3, e: 4 }
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.6" do
|
||||
ruby_version_is ""..."2.5.1" do
|
||||
it "partially modifies the contents if we broke from the block" do
|
||||
@hash.transform_keys! do |v|
|
||||
break if v == :c
|
||||
|
@ -85,7 +85,7 @@ ruby_version_is "2.5" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
ruby_version_is "2.5.1" do
|
||||
it "returns the processed keys if we broke from the block" do
|
||||
@hash.transform_keys! do |v|
|
||||
break if v == :c
|
||||
|
|
|
@ -104,6 +104,20 @@ describe "Module#prepend" do
|
|||
c.new.alias.should == :m
|
||||
end
|
||||
|
||||
it "reports the class for the owner of an aliased method on the class" do
|
||||
m = Module.new
|
||||
c = Class.new { prepend(m); def meth; :c end; alias_method :alias, :meth }
|
||||
c.instance_method(:alias).owner.should == c
|
||||
end
|
||||
|
||||
ruby_version_is "2.3" do
|
||||
it "reports the class for the owner of a method aliased from the prepended module" do
|
||||
m = Module.new { def meth; :m end }
|
||||
c = Class.new { prepend(m); alias_method :alias, :meth }
|
||||
c.instance_method(:alias).owner.should == c
|
||||
end
|
||||
end
|
||||
|
||||
it "sees an instance of a prepended class as kind of the prepended module" do
|
||||
m = Module.new
|
||||
c = Class.new { prepend(m) }
|
||||
|
|
|
@ -52,42 +52,46 @@ describe "Module#private" do
|
|||
end.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "only makes the method private in the class it is called on" do
|
||||
base = Class.new do
|
||||
def wrapped
|
||||
1
|
||||
ruby_version_is "2.3" do
|
||||
ruby_bug "#14604", "2.3"..."2.5.1" do
|
||||
it "only makes the method private in the class it is called on" do
|
||||
base = Class.new do
|
||||
def wrapped
|
||||
1
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new(base) do
|
||||
def wrapped
|
||||
super + 1
|
||||
end
|
||||
private :wrapped
|
||||
end
|
||||
|
||||
base.new.wrapped.should == 1
|
||||
lambda do
|
||||
klass.new.wrapped
|
||||
end.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "continues to allow a prepended module method to call super" do
|
||||
wrapper = Module.new do
|
||||
def wrapped
|
||||
super + 1
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new do
|
||||
prepend wrapper
|
||||
|
||||
def wrapped
|
||||
1
|
||||
end
|
||||
private :wrapped
|
||||
end
|
||||
|
||||
klass.new.wrapped.should == 2
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new(base) do
|
||||
def wrapped
|
||||
super + 1
|
||||
end
|
||||
private :wrapped
|
||||
end
|
||||
|
||||
base.new.wrapped.should == 1
|
||||
lambda do
|
||||
klass.new.wrapped
|
||||
end.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "continues to allow a prepended module method to call super" do
|
||||
wrapper = Module.new do
|
||||
def wrapped
|
||||
super + 1
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new do
|
||||
prepend wrapper
|
||||
|
||||
def wrapped
|
||||
1
|
||||
end
|
||||
private :wrapped
|
||||
end
|
||||
|
||||
klass.new.wrapped.should == 2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ describe :process_spawn_does_not_close_std_streams, shared: true do
|
|||
code = "STDERR.puts 'hello'"
|
||||
cmd = "Process.wait Process.spawn(#{ruby_cmd(code).inspect}, #{@options.inspect})"
|
||||
ruby_exe(cmd, args: "2> #{@output}")
|
||||
File.binread(@output).should == "hello#{newline}"
|
||||
File.binread(@output).should =~ /hello#{newline}/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -195,26 +195,34 @@ describe "The rescue keyword" do
|
|||
ScratchPad.recorded.should == [:one, :else_ran, :ensure_ran, :outside_begin]
|
||||
end
|
||||
|
||||
else_without_rescue = lambda {
|
||||
eval <<-ruby
|
||||
begin
|
||||
ScratchPad << :begin
|
||||
else
|
||||
ScratchPad << :else
|
||||
end
|
||||
ruby
|
||||
}
|
||||
|
||||
ruby_version_is ""..."2.6" do
|
||||
ruby_version_is ''...'2.6' do
|
||||
it "will execute an else block even without rescue and ensure" do
|
||||
else_without_rescue.should complain(/else without rescue is useless/)
|
||||
lambda {
|
||||
eval <<-ruby
|
||||
begin
|
||||
ScratchPad << :begin
|
||||
else
|
||||
ScratchPad << :else
|
||||
end
|
||||
ruby
|
||||
}.should complain(/else without rescue is useless/)
|
||||
|
||||
ScratchPad.recorded.should == [:begin, :else]
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
else_without_rescue.should raise_error(SyntaxError)
|
||||
ruby_version_is '2.6' do
|
||||
it "raises SyntaxError when else is used without rescue and ensure" do
|
||||
lambda {
|
||||
eval <<-ruby
|
||||
begin
|
||||
ScratchPad << :begin
|
||||
else
|
||||
ScratchPad << :else
|
||||
end
|
||||
ruby
|
||||
}.should raise_error(SyntaxError, /else without rescue is useless/)
|
||||
end
|
||||
end
|
||||
|
||||
it "will not execute an else block if an exception was raised" do
|
||||
|
|
Loading…
Reference in a new issue