summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-26 20:48:21 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-26 20:48:21 +0000
commit9245e097ecf201f0f5eaeff307b1403d97c2318b (patch)
tree849596b8af99adbef2ecff5d769928b33d3e5048 /spec
parent6c2b58986508b82896eefeaf195be0aa506eaa45 (diff)
Update to ruby/spec@a585ec3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/dir/glob_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/lazy/uniq_spec.rb26
-rw-r--r--spec/ruby/core/hash/transform_keys_spec.rb8
-rw-r--r--spec/ruby/core/module/prepend_spec.rb14
-rw-r--r--spec/ruby/core/module/private_spec.rb64
-rw-r--r--spec/ruby/core/process/spawn_spec.rb2
-rw-r--r--spec/ruby/language/rescue_spec.rb36
7 files changed, 103 insertions, 59 deletions
diff --git a/spec/ruby/core/dir/glob_spec.rb b/spec/ruby/core/dir/glob_spec.rb
index c5edcc35d5..4b437b0e24 100644
--- a/spec/ruby/core/dir/glob_spec.rb
+++ b/spec/ruby/core/dir/glob_spec.rb
@@ -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'
diff --git a/spec/ruby/core/enumerator/lazy/uniq_spec.rb b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
index d31e816faf..3c9acdc453 100644
--- a/spec/ruby/core/enumerator/lazy/uniq_spec.rb
+++ b/spec/ruby/core/enumerator/lazy/uniq_spec.rb
@@ -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
diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb
index 4b3937b251..32ac89b765 100644
--- a/spec/ruby/core/hash/transform_keys_spec.rb
+++ b/spec/ruby/core/hash/transform_keys_spec.rb
@@ -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
diff --git a/spec/ruby/core/module/prepend_spec.rb b/spec/ruby/core/module/prepend_spec.rb
index b586596c12..35b31f1fb0 100644
--- a/spec/ruby/core/module/prepend_spec.rb
+++ b/spec/ruby/core/module/prepend_spec.rb
@@ -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) }
diff --git a/spec/ruby/core/module/private_spec.rb b/spec/ruby/core/module/private_spec.rb
index 5d85c34855..bf3e86a333 100644
--- a/spec/ruby/core/module/private_spec.rb
+++ b/spec/ruby/core/module/private_spec.rb
@@ -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
- 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
- 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
- klass = Class.new do
- prepend wrapper
+ def wrapped
+ 1
+ end
+ private :wrapped
+ end
- def wrapped
- 1
+ klass.new.wrapped.should == 2
end
- private :wrapped
end
-
- klass.new.wrapped.should == 2
end
end
diff --git a/spec/ruby/core/process/spawn_spec.rb b/spec/ruby/core/process/spawn_spec.rb
index 4de7d9a369..1bd1dfac83 100644
--- a/spec/ruby/core/process/spawn_spec.rb
+++ b/spec/ruby/core/process/spawn_spec.rb
@@ -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
diff --git a/spec/ruby/language/rescue_spec.rb b/spec/ruby/language/rescue_spec.rb
index 66a493cd34..5336265775 100644
--- a/spec/ruby/language/rescue_spec.rb
+++ b/spec/ruby/language/rescue_spec.rb
@@ -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