Permalink
Browse files

Updated CI specs to RubySpec fbd4517b.

  • Loading branch information...
1 parent 842d0fb commit 4ed534ee90ff19a5acfc47a68c5025ddb5f3e1a8 Brian Ford committed Jun 21, 2011
Showing with 299 additions and 108 deletions.
  1. +12 −3 spec/ruby/core/class/dup_spec.rb
  2. +15 −1 spec/ruby/core/enumerable/fixtures/classes.rb
  3. +7 −0 spec/ruby/core/enumerable/zip_spec.rb
  4. +12 −3 spec/ruby/core/env/element_reference_spec.rb
  5. +15 −1 spec/ruby/core/file/sticky_spec.rb
  6. +1 −0 spec/ruby/core/io/shared/each.rb
  7. +9 −2 spec/ruby/core/kernel/autoload_spec.rb
  8. +5 −0 spec/ruby/core/kernel/fixtures/autoload_d.rb
  9. BIN spec/ruby/core/marshal/fixtures/random.dump
  10. +1 −1 spec/ruby/core/method/fixtures/classes_1.9.rb
  11. +13 −1 spec/ruby/core/module/autoload_spec.rb
  12. +4 −5 spec/ruby/core/proc/curry_spec.rb
  13. +4 −0 spec/ruby/core/proc/fixtures/common.rb
  14. +48 −9 spec/ruby/core/proc/lambda_spec.rb
  15. +6 −3 spec/ruby/core/process/maxgroups_spec.rb
  16. +27 −15 spec/ruby/core/string/shared/to_sym.rb
  17. +14 −4 spec/ruby/core/thread/shared/start.rb
  18. +12 −4 spec/ruby/library/bigdecimal/new_spec.rb
  19. +2 −2 spec/ruby/library/date/gregorian_spec.rb
  20. +2 −2 spec/ruby/library/date/julian_spec.rb
  21. +8 −15 spec/ruby/library/date/shared/civil.rb
  22. +2 −2 spec/ruby/library/datetime/new_spec.rb
  23. +7 −1 spec/ruby/library/etc/getlogin_spec.rb
  24. +5 −5 spec/ruby/library/net/http/http/get_spec.rb
  25. +22 −23 spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb
  26. +20 −0 spec/ruby/library/openstruct/method_missing_spec.rb
  27. +3 −3 spec/ruby/library/socket/fixtures/classes.rb
  28. +8 −1 spec/ruby/library/socket/socket/connect_nonblock_spec.rb
  29. +1 −0 spec/ruby/library/yaml/fixtures/common.rb
  30. +9 −1 spec/ruby/optional/capi/ext/time_spec.c
  31. +3 −0 spec/ruby/optional/capi/spec_helper.rb
  32. +2 −1 spec/ruby/optional/capi/time_spec.rb
@@ -37,9 +37,18 @@ def self.message
klass_dup.message.should == "text"
end
- it "removes the name from the class if not assigned to a constant" do
- copy = CoreClassSpecs::Record.dup
- copy.name.should == ""
+ ruby_version_is ""..."1.9" do
+ it "sets the name from the class to \"\" if not assigned to a constant" do
+ copy = CoreClassSpecs::Record.dup
+ copy.name.should == ""
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "sets the name from the class to nil if not assigned to a constant" do
+ copy = CoreClassSpecs::Record.dup
+ copy.name.should be_nil
+ end
end
it "stores the new name if assigned to a constant" do
@@ -107,7 +107,7 @@ def <=>(other)
class ArrayConvertable
attr_accessor :called
def initialize(*values)
- @values = values;
+ @values = values
end
def to_a
@@ -120,6 +120,20 @@ def to_ary
@values
end
end
+
+ class EnumConvertable
+ attr_accessor :called
+ attr_accessor :sym
+ def initialize(delegate)
+ @delegate = delegate
+ end
+
+ def to_enum(sym)
+ self.called = :to_enum
+ self.sym = sym
+ @delegate.to_enum(sym)
+ end
+ end
class Equals
def initialize(obj)
@@ -34,6 +34,13 @@
EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
convertable.called.should == :to_ary
end
+
+ it "converts arguments to arrays using #to_ary" do
+ convertable = EnumerableSpecs::EnumConvertable.new(4..6)
+ EnumerableSpecs::Numerous.new(1,2,3).zip(convertable).should == [[1,4],[2,5],[3,6]]
+ convertable.called.should == :to_enum
+ convertable.sym.should == :each
+ end
end
end
@@ -9,22 +9,31 @@
end
it "returns the specified environment variable" do
- ENV[@variable_name].should == username
+ # username may masked by chroot or sudo
+ if ENV[@variable_name]
+ ENV[@variable_name].should == username
+ else
+ ENV[@variable_name].should be_nil
+ end
end
it "returns nil if the variable isn't found" do
ENV["this_var_is_never_set"].should == nil
end
it "returns only frozen values" do
- ENV[@variable_name].frozen?.should == true
+ if ENV[@variable_name]
+ ENV[@variable_name].frozen?.should == true
+ end
ENV["returns_only_frozen_values"] = "a non-frozen string"
ENV["returns_only_frozen_values"].frozen?.should == true
end
ruby_version_is "1.9" do
it "uses the locale encoding" do
- ENV[@variable_name].encoding.should == Encoding.find('locale')
+ if ENV[@variable_name]
+ ENV[@variable_name].encoding.should == Encoding.find('locale')
+ end
ENV["uses_the_locale_encoding"] = "a binary string".force_encoding('binary')
ENV["uses_the_locale_encoding"].encoding.should == Encoding.find('locale')
end
@@ -20,7 +20,7 @@
rm_r filename
end
- platform_is_not :windows do
+ platform_is :linux, :darwin do
it "returns true if the file has sticky bit set" do
filename = tmp("i_exist")
touch(filename)
@@ -31,4 +31,18 @@
rm_r filename
end
end
+
+ platform_is :bsd do
+ # FreeBSD and NetBSD can't set stiky bit to a normal file
+ it "cannot set sticky bit to a normal file" do
+ filename = tmp("i_exist")
+ touch(filename)
+ stat = File.stat(filename)
+ mode = stat.mode
+ raise_error(Errno::EFTYPE){File.chmod(mode|01000, filename)}
+ File.sticky?(filename).should == false
+
+ rm_r filename
+ end
+ end
end
@@ -53,6 +53,7 @@
@io.send(@method) { ScratchPad << $. }
ScratchPad.recorded.should == [ 1,2,3,4,5,6,7,8,9 ]
end
+
ruby_version_is "" ... "1.8.7" do
it "raises a LocalJumpError when passed no block" do
lambda { @io.send(@method) }.should raise_error(LocalJumpError)
@@ -7,6 +7,7 @@
autoload :KSAutoloadA, "autoload_a.rb"
autoload :KSAutoloadB, fixture(__FILE__, "autoload_b.rb")
+autoload :KSAutoloadC, fixture(__FILE__, "autoload_c.rb")
def check_autoload(const)
autoload? const
@@ -42,12 +43,18 @@ def check_autoload(const)
end
it "does not call Kernel.require or Kernel.load to load the file" do
- filename = fixture(__FILE__, "autoload_c.rb")
- autoload :KSAutoloadC, filename
Kernel.should_not_receive(:require)
Kernel.should_not_receive(:load)
KSAutoloadC.loaded.should == :ksautoload_c
end
+
+ it "can autoload in instance_eval" do
+ instance_eval do
+ # this instance_eval is not needed because specs are run in instance_eval
+ autoload :KSAutoloadD, fixture(__FILE__, "autoload_d.rb")
+ KSAutoloadD.loaded.should == :ksautoload_d
+ end
+ end
end
describe "Kernel#autoload?" do
@@ -0,0 +1,5 @@
+module KSAutoloadD
+ def self.loaded
+ :ksautoload_d
+ end
+end
Binary file not shown.
@@ -3,7 +3,7 @@ module MethodSpecs
class Methods
def one_splat_one_req(*a,b); end
def one_splat_two_req(*a,b,c); end
- def one_splat_one_req_with_block(*a,b,&block); end
+ def one_splat_one_req_with_block(*a,b,&blk); end
def one_opt_with_stabby(a=->(b){true}); end
end
@@ -196,8 +196,10 @@ module ModuleSpecs::Autoload::Q
lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should have_constant(:O)
end
+ end
- it "does not load the file when refering to the constant in defined?" do
+ ruby_version_is '1.9' ... '1.9.3' do
+ it "return nil on refering the constant with defined?()" do
module ModuleSpecs::Autoload::Q
autoload :R, fixture(__FILE__, "autoload.rb")
defined?(R).should be_nil
@@ -206,6 +208,16 @@ module ModuleSpecs::Autoload::Q
end
end
+ ruby_version_is '1.9.3' do
+ it "return 'constant' on refering the constant with defined?()" do
+ module ModuleSpecs::Autoload::Q
+ autoload :R, fixture(__FILE__, "autoload.rb")
+ defined?(R).should == 'constant'
+ end
+ ModuleSpecs::Autoload::Q.should have_constant(:R)
+ end
+ end
+
it "does not load the file when removing an autoload constant" do
module ModuleSpecs::Autoload::Q
autoload :R, fixture(__FILE__, "autoload.rb")
@@ -3,7 +3,7 @@
ruby_version_is "1.9" do
describe "Proc#curry" do
before(:each) do
- @proc_add = proc {|x,y,z| (x||0) + (y||0) + (z||0) }
+ @proc_add = Proc.new {|x,y,z| (x||0) + (y||0) + (z||0) }
@lambda_add = lambda {|x,y,z| (x||0) + (y||0) + (z||0) }
end
@@ -88,13 +88,12 @@
end
it "raises an ArgumentError if called on a lambda that requires more than _arity_ arguments" do
- p = lambda { true }
- lambda { p.curry(2) }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(2) }.should raise_error(ArgumentError)
+ lambda { lambda{|x, y, z, *more|}.curry(2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if called on a lambda that requires fewer than _arity_ arguments" do
- p = lambda { true }
- lambda { p.curry(4) }.should raise_error(ArgumentError)
+ lambda { @lambda_add.curry(4) }.should raise_error(ArgumentError)
end
it "calls the curried proc with the arguments if _arity_ arguments have been given" do
@@ -3,6 +3,10 @@ def self.new_proc_in_method
Proc.new
end
+ def self.new_proc_from_amp(&block)
+ block
+ end
+
class ProcSubclass < Proc
end
@@ -1,23 +1,62 @@
require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/common', __FILE__)
ruby_version_is "1.9" do
describe "Proc#lambda?" do
- it "returns true if the object was created with the lambda keyword" do
- lambda { true }.lambda?.should be_true
+ it "returns true if the Proc was created from a block with the lambda keyword" do
+ lambda {}.lambda?.should be_true
end
- it "returns false if the object was created with the proc keyword" do
- proc { true }.lambda?.should be_false
+ it "returns false if the Proc was created from a block with the proc keyword" do
+ proc {}.lambda?.should be_false
end
- it "returns false if the object was created with Proc.new" do
- Proc.new { true }.lambda?.should be_false
+ it "returns false if the Proc was created from a block with Proc.new" do
+ Proc.new {}.lambda?.should be_false
+ end
+
+ it "is preserved when passing a Proc with & to the lambda keyword" do
+ lambda(&lambda{}).lambda?.should be_true
+ lambda(&proc{}).lambda?.should be_false
+ end
+
+ it "is preserved when passing a Proc with & to the proc keyword" do
+ proc(&lambda{}).lambda?.should be_true
+ proc(&proc{}).lambda?.should be_false
+ end
+
+ it "is preserved when passing a Proc with & to Proc.new" do
+ Proc.new(&lambda{}).lambda?.should be_true
+ Proc.new(&proc{}).lambda?.should be_false
+ end
+
+ it "returns false if the Proc was created from a block with &" do
+ ProcSpecs.new_proc_from_amp{}.lambda?.should be_false
+ end
+
+ it "is preserved when the Proc was passed using &" do
+ ProcSpecs.new_proc_from_amp(&lambda{}).lambda?.should be_true
+ ProcSpecs.new_proc_from_amp(&proc{}).lambda?.should be_false
+ ProcSpecs.new_proc_from_amp(&Proc.new{}).lambda?.should be_false
+ end
+
+ it "returns true for a Method converted to a Proc" do
+ m = :foo.method(:to_s)
+ m.to_proc.lambda?.should be_true
+ ProcSpecs.new_proc_from_amp(&m).lambda?.should be_true
end
# [ruby-core:24127]
- it "returns true if the object was created with Proc#curry" do
- l = lambda { true }
- l.curry.lambda?.should be_true
+ it "is preserved when a Proc is curried" do
+ lambda{}.curry.lambda?.should be_true
+ proc{}.curry.lambda?.should be_false
+ Proc.new{}.curry.lambda?.should be_false
+ end
+
+ it "is preserved when a curried Proc is called without enough arguments" do
+ lambda{|x,y|}.curry.call(42).lambda?.should be_true
+ proc{|x,y|}.curry.call(42).lambda?.should be_false
+ Proc.new{|x,y|}.curry.call(42).lambda?.should be_false
end
end
end
@@ -7,9 +7,12 @@
it "sets the maximum number of gids allowed in the supplemental group access list" do
n = Process.maxgroups
- Process.maxgroups = n + 1
- Process.maxgroups.should == n + 1
- Process.maxgroups = n
+ begin
+ Process.maxgroups = n - 1
+ Process.maxgroups.should == n - 1
+ ensure
+ Process.maxgroups = n
+ end
end
end
@@ -7,30 +7,42 @@
"abc=".send(@method).should == :abc=
end
- it "special cases !@ and ~@" do
- "!@".to_sym.should == :"!"
- "~@".to_sym.should == :~
- end
-
- it "special cases !(unary) and ~(unary)" do
- "!(unary)".to_sym.should == :"!"
- "~(unary)".to_sym.should == :~
- end
-
it "special cases +(binary) and -(binary)" do
"+(binary)".to_sym.should == :+
"-(binary)".to_sym.should == :-
end
- it "special cases +(unary) and -(unary)" do
- "+(unary)".to_sym.should == :"+@"
- "-(unary)".to_sym.should == :"-@"
- end
-
ruby_version_is ""..."1.9" do
+ it "special cases !@ and ~@" do
+ "!@".to_sym.should == :"!"
+ "~@".to_sym.should == :~
+ end
+
+ it "special cases !(unary) and ~(unary)" do
+ "!(unary)".to_sym.should == :"!"
+ "~(unary)".to_sym.should == :~
+ end
+
+ it "special cases +(unary) and -(unary)" do
+ "+(unary)".to_sym.should == :"+@"
+ "-(unary)".to_sym.should == :"-@"
+ end
+
it "raises an ArgumentError when self can't be converted to symbol" do
lambda { "".send(@method) }.should raise_error(ArgumentError)
lambda { "foo\x00bar".send(@method) }.should raise_error(ArgumentError)
end
end
+
+ ruby_version_is "1.9" do
+ it "does not special case certain operators" do
+ [ ["!@", :"!@"],
+ ["~@", :"~@"],
+ ["!(unary)", :"!(unary)"],
+ ["~(unary)", :"~(unary)"],
+ ["+(unary)", :"+(unary)"],
+ ["-(unary)", :"-(unary)"]
+ ].should be_computed_by(:to_sym)
+ end
+ end
end
Oops, something went wrong.

0 comments on commit 4ed534e

Please sign in to comment.