Skip to content
Browse files

Updated CI specs to RubySpec 56c5528f.

  • Loading branch information...
1 parent 7aa541e commit a842e3734de5251168af6d72387855c0109ed503 @brixen brixen committed Feb 21, 2013
View
1 spec/ruby/.gitignore
@@ -13,6 +13,7 @@
optional/ffi/fixtures/build
jruby.1.8.mspec
jruby.1.9.mspec
+rubyspec_temp
# We have to generate this file because it was removed in 1.9.
optional/capi/ext/rubyspec_version.h
View
3 spec/ruby/Gemfile
@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+gem 'mspec', :github => 'rubyspec/mspec'
+gem 'ffi', :github => 'ffi/ffi'
View
1 spec/ruby/README → spec/ruby/README.md
@@ -6,6 +6,7 @@ The RubySpec files are written using RSpec-compatible syntax. MSpec is a
purpose-built framework for running RubySpec. For more information, see the
http://github.com/rubyspec/mspec project.
+[![Build Status](https://travis-ci.org/rubyspec/rubyspec.png)](https://travis-ci.org/rubyspec/rubyspec)
1. Installing MSpec
View
2 spec/ruby/core/main/fixtures/classes.rb
@@ -4,8 +4,6 @@ module Module
module WrapIncludeModule
end
-
- DATA = {}
end
def main_public_method
View
7 spec/ruby/core/main/fixtures/string_refinement.rb
@@ -1,7 +0,0 @@
-module StringRefinement
- refine(String) do
- def foo
- 'foo'
- end
- end
-end
View
11 spec/ruby/core/main/fixtures/string_refinement_user.rb
@@ -1,11 +0,0 @@
-using StringRefinement
-
-module MainSpecs
- DATA[:in_module] = 'hello'.foo
-
- def self.call_foo(x)
- x.foo
- end
-end
-
-MainSpecs::DATA[:toplevel] = 'hello'.foo
View
132 spec/ruby/core/main/using_spec.rb
@@ -1,132 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-ruby_version_is "2.0.0" do
- require File.expand_path('../fixtures/classes', __FILE__)
- require File.expand_path('../fixtures/string_refinement', __FILE__)
-
- describe "main.using" do
- it "requires one Module argument" do
- lambda do
- eval('using', TOPLEVEL_BINDING)
- end.should raise_error(ArgumentError)
-
- lambda do
- eval('using "foo"', TOPLEVEL_BINDING)
- end.should raise_error(TypeError)
- end
-
- it "uses refinements from the given module only in the target file" do
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- MainSpecs::DATA[:in_module].should == 'foo'
- MainSpecs::DATA[:toplevel].should == 'foo'
- lambda do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- end
-
- it "uses refinements from the given module for method calls in the target file" do
- load File.expand_path('../fixtures/string_refinement_user.rb', __FILE__)
- lambda do
- 'hello'.foo
- end.should raise_error(NoMethodError)
- MainSpecs.call_foo('hello').should == 'foo'
- end
-
- it "uses refinements from the given module in the eval string" do
- cls = MainSpecs::DATA[:cls] = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
- end
- eval(<<-EOS, TOPLEVEL_BINDING).should == 'bar'
- using MainSpecs::DATA[:mod]
- MainSpecs::DATA[:cls].new.foo
- EOS
- end
-
- it "does not affect methods defined before it is called" do
- cls = Class.new {def foo; 'foo'; end}
- MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'bar'; end
- end
- end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- x = MainSpecs::DATA[:x]
- def x.before_using(obj)
- obj.foo
- end
- using MainSpecs::DATA[:mod]
- def x.after_using(obj)
- obj.foo
- end
- EOS
-
- x.before_using(cls.new).should == 'foo'
- x.after_using(cls.new).should == 'bar'
- end
-
- it "propagates refinements added to existing modules after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
- end
- end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
- end
- EOS
-
- x.call_foo(cls.new).should == 'quux'
-
- mod.module_eval do
- refine(cls) do
- def bar; 'quux'; end
- end
- end
-
- x.call_bar(cls.new).should == 'quux'
- end
-
- it "does not propagate refinements of new modules added after it is called" do
- cls = Class.new {def foo; 'foo'; end}
- cls2 = Class.new {def bar; 'bar'; end}
- mod = MainSpecs::DATA[:mod] = Module.new do
- refine(cls) do
- def foo; 'quux'; end
- end
- end
- x = MainSpecs::DATA[:x] = Object.new
- eval <<-EOS, TOPLEVEL_BINDING
- using MainSpecs::DATA[:mod]
- x = MainSpecs::DATA[:x]
- def x.call_foo(obj)
- obj.foo
- end
- def x.call_bar(obj)
- obj.bar
- end
- EOS
-
- x.call_foo(cls.new).should == 'quux'
-
- mod.module_eval do
- refine(cls2) do
- def bar; 'quux'; end
- end
- end
-
- x.call_bar(cls2.new).should == 'bar'
- end
- end
-end
View
104 spec/ruby/core/module/refine_spec.rb
@@ -1,104 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-ruby_version_is "2.0.0" do
- describe "Module#refine" do
- it "runs its block in an anonymous Module" do
- selves = nil
- mod = Module.new do
- outer_self = self
- refine String do
- selves = [outer_self, self]
- end
- end
-
- selves[0].should == mod
- selves[0].should_not == selves[1]
- selves[1].should be_kind_of(Module)
- end
-
- it "uses the same anonymous module for future refines of the same class" do
- selves = []
- mod = Module.new do
- selves << self
- refine String do
- selves << self
- end
- end
-
- mod.module_eval do
- refine String do
- selves << self
- end
- end
-
- selves[1].should == selves[2]
- end
-
- it "adds methods defined in its block to the anon module's public instance methods" do
- inner_self = nil
- mod = Module.new do
- refine String do
- def blah
- "blah"
- end
- inner_self = self
- end
- end
-
- inner_self.public_instance_methods.should include(:blah)
- end
-
- it "raises ArgumentError if not passed an argument" do
- lambda do
- Module.new do
- refine {}
- end
- end.should raise_error(ArgumentError)
- end
-
- it "raises TypeError if not passed a class or module" do
- lambda do
- Module.new do
- refine('foo') {}
- end
- end.should raise_error(TypeError)
- end
-
- it "raises ArgumentError if not given a block" do
- lambda do
- Module.new do
- refine String
- end
- end.should raise_error(ArgumentError)
- end
-
- it "applies refinements to calls in the refine block" do
- result = nil
- Module.new do
- refine(String) do
- def foo; 'foo'; end
- result = 'hello'.foo
- end
- end
- result.should == 'foo'
- end
-
- it "doesn't apply refinements outside the refine block" do
- Module.new do
- refine(String) {def foo; 'foo'; end}
- lambda do
- 'hello'.foo
- end
- should raise_error(NoMethodError)
- end
- end
-
- it "does not apply refinements to external scopes not using the module" do
- Module.new do
- refine(String) {def foo; 'foo'; end}
- end
-
- lambda {'hello'.foo}.should raise_error(NoMethodError)
- end
- end
-end
View
1 spec/ruby/optional/capi/encoding_spec.rb
@@ -223,6 +223,7 @@
describe "ENC_CODERANGE_ASCIIONLY" do
it "returns true if the object encoding is only ASCII" do
str = encode("abc", "us-ascii")
+ str.valid_encoding? # make sure to set the coderange
@s.ENC_CODERANGE_ASCIIONLY(str).should be_true
end
View
4 spec/ruby/optional/capi/ext/kernel_spec.c
@@ -35,7 +35,7 @@ VALUE kernel_spec_rb_block_proc(VALUE self) {
#ifdef HAVE_RB_BLOCK_CALL
VALUE block_call_inject(VALUE yield_value, VALUE data2) {
- // yield_value yields the first block argument
+ /* yield_value yields the first block argument */
VALUE elem = yield_value;
VALUE elem_incr = INT2FIX(FIX2INT(elem) + 1);
return elem_incr;
@@ -47,7 +47,7 @@ VALUE kernel_spec_rb_block_call(VALUE self, VALUE ary) {
#ifdef RUBY_VERSION_IS_1_9
VALUE block_call_inject_multi_arg(VALUE yield_value, VALUE data2, int argc, VALUE argv[]) {
- // yield_value yields the first block argument
+ /* yield_value yields the first block argument */
VALUE sum = yield_value;
VALUE elem = argv[1];
View
2 spec/ruby/optional/capi/ext/mri.h
@@ -18,6 +18,8 @@
#undef HAVE_RBIGNUM_POSITIVE_P
#undef HAVE_RBIGNUM_NEGATIVE_P
#undef HAVE_RB_STR_SET_LEN
+#undef HAVE_RB_BLOCK_CALL
+#undef HAVE_RB_OBJ_METHOD
#endif
#ifdef RUBY_VERSION_IS_1_8_EX_1_9
View
4 spec/ruby/optional/capi/ext/rubyspec.h
@@ -320,15 +320,15 @@
#define HAVE_RB_RESCUE2 1
#define HAVE_RB_SET_END_PROC 1
#define HAVE_RB_SYS_FAIL 1
-#ifdef RUBY_VERSION_IS_1_9
+#ifdef RUBY_VERSION_IS_1_9_3
#define HAVE_RB_SYSERR_FAIL 1
+#define HAVE_RB_MAKE_BACKTRACE 1
#endif
#define HAVE_RB_THROW 1
#define HAVE_RB_CATCH 1
#ifdef RUBY_VERSION_IS_1_9
#define HAVE_RB_THROW_OBJ 1
#define HAVE_RB_CATCH_OBJ 1
-#define HAVE_RB_MAKE_BACKTRACE 1
#endif
#define HAVE_RB_WARN 1
#define HAVE_RB_YIELD 1
View
6 spec/ruby/optional/capi/ext/thread_spec.c
@@ -40,6 +40,7 @@ static void unblock_func(void *data) {
}
/* Returns true if the thread is interrupted. */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static VALUE thread_spec_rb_thread_blocking_region(VALUE self) {
int fds[2];
VALUE ret;
@@ -53,6 +54,7 @@ static VALUE thread_spec_rb_thread_blocking_region(VALUE self) {
close(fds[1]);
return ret;
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
/* This is unblocked by a signal. */
static VALUE blocking_func_for_udf_io(void *data) {
@@ -67,6 +69,7 @@ static VALUE blocking_func_for_udf_io(void *data) {
}
/* Returns true if the thread is interrupted. */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static VALUE thread_spec_rb_thread_blocking_region_with_ubf_io(VALUE self) {
int fds[2];
VALUE ret;
@@ -81,6 +84,7 @@ static VALUE thread_spec_rb_thread_blocking_region_with_ubf_io(VALUE self) {
close(fds[1]);
return ret;
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#endif
#ifdef HAVE_RB_THREAD_CURRENT
@@ -102,6 +106,7 @@ static VALUE thread_spec_rb_thread_local_aset(VALUE self, VALUE thr, VALUE sym,
#endif
#ifdef HAVE_RB_THREAD_SELECT
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static VALUE thread_spec_rb_thread_select_fd(VALUE self, VALUE fd_num, VALUE msec) {
int fd = NUM2INT(fd_num);
struct timeval tv;
@@ -125,6 +130,7 @@ static VALUE thread_spec_rb_thread_select(VALUE self, VALUE msec) {
rb_thread_select(0, NULL, NULL, NULL, &tv);
return Qnil;
}
+#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#endif
#ifdef HAVE_RB_THREAD_WAKEUP
View
70 spec/ruby/optional/capi/kernel_spec.rb
@@ -27,32 +27,34 @@
end
end
- describe "rb_block_call" do
- before :each do
- ScratchPad.record []
- end
-
- it "calls the block with a single argument" do
- ary = [1, 3, 5]
- @s.rb_block_call(ary).should == [2, 4, 6]
- end
-
- ruby_version_is "1.9" do
- it "calls the block with multiple arguments in argc / argv" do
- ary = [1, 3, 5]
- @s.rb_block_call_multi_arg(ary).should == 9
+ ruby_version_is "1.8.7" do
+ describe "rb_block_call" do
+ before :each do
+ ScratchPad.record []
end
- it "calls the method with no function callback and no block" do
+ it "calls the block with a single argument" do
ary = [1, 3, 5]
- @s.rb_block_call_no_func(ary).should be_kind_of(Enumerator)
+ @s.rb_block_call(ary).should == [2, 4, 6]
end
- it "calls the method with no function callback and a block" do
- ary = [1, 3, 5]
- @s.rb_block_call_no_func(ary) do |i|
- i + 1
- end.should == [2, 4, 6]
+ ruby_version_is "1.9" do
+ it "calls the block with multiple arguments in argc / argv" do
+ ary = [1, 3, 5]
+ @s.rb_block_call_multi_arg(ary).should == 9
+ end
+
+ it "calls the method with no function callback and no block" do
+ ary = [1, 3, 5]
+ @s.rb_block_call_no_func(ary).should be_kind_of(Enumerator)
+ end
+
+ it "calls the method with no function callback and a block" do
+ ary = [1, 3, 5]
+ @s.rb_block_call_no_func(ary) do |i|
+ i + 1
+ end.should == [2, 4, 6]
+ end
end
end
end
@@ -168,7 +170,7 @@
end
end
- ruby_version_is "1.9" do
+ ruby_version_is "1.9.3" do
describe "rb_syserr_fail" do
it "raises an exception from the given error" do
lambda do
@@ -421,7 +423,7 @@
end
end
- ruby_version_is "1.9" do
+ ruby_version_is "1.9.3" do
describe "rb_make_backtrace" do
it "returns a caller backtrace" do
backtrace = @s.rb_make_backtrace
@@ -431,17 +433,19 @@
end
end
- describe "rb_obj_method" do
- it "returns the method object for a symbol" do
- method = @s.rb_obj_method("test", :size)
- method.owner.should == String
- method.name.to_sym.should == :size
- end
+ ruby_version_is "1.8.7" do
+ describe "rb_obj_method" do
+ it "returns the method object for a symbol" do
+ method = @s.rb_obj_method("test", :size)
+ method.owner.should == String
+ method.name.to_sym.should == :size
+ end
- it "returns the method object for a string" do
- method = @s.rb_obj_method("test", "size")
- method.owner.should == String
- method.name.to_sym.should == :size
+ it "returns the method object for a string" do
+ method = @s.rb_obj_method("test", "size")
+ method.owner.should == String
+ method.name.to_sym.should == :size
+ end
end
end
end
View
12 spec/ruby/optional/capi/proc_spec.rb
@@ -24,6 +24,10 @@
@prc[:foo_bar].should == "[:foo_bar]"
@prc[[:foo, :bar]].should == "[:foo, :bar]"
end
+
+ it "returns a Proc instance correctly described in #inspect with source location" do
+ @prc.inspect.should =~ /^#<Proc:0x[0-9a-f]*@.*:\d+>$/
+ end
end
ruby_version_is "1.8.7" ... "1.9" do
@@ -48,16 +52,16 @@
@prc[:foo_bar].should == ":foo_bar"
@prc[[:foo, :bar]].should == "[:foo, :bar]"
end
+
+ it "returns a Proc instance correctly described in #inspect without source location" do
+ @prc.inspect.should =~ /^#<Proc:([^ :@]*?)>$/
+ end
end
it "returns a Proc instance with #aricy == -1" do
@prc.arity.should == -1
end
- it "returns a Proc instance correctly described in #inspect without source location" do
- @prc.inspect.should =~ /^#<Proc:([^ :@]*?)>$/
- end
-
it "shouldn't be equal to another one" do
@prc.should_not == @p.rb_proc_new
end
View
68 spec/ruby/optional/capi/util_spec.rb
@@ -88,7 +88,9 @@
@o.rb_scan_args([1, 2, 3, 4], "01*1", 3, @acc).should == 4
ScratchPad.recorded.should == [1, [2, 3], 4]
end
+ end
+ ruby_version_is "1.9.3" do
it "assigns required, optional, splat, post-splat and block arguments" do
@o.rb_scan_args([1, 2, 3, 4, 5], "11*1&", 5, @acc, &@prc).should == 5
ScratchPad.recorded.should == [1, 2, [3, 4], 5, @prc]
@@ -125,34 +127,66 @@
end
end
- describe "rb_iter_break" do
+ ruby_version_is ""..."1.9" do
+ describe "rb_iter_break" do
- before :each do
- ScratchPad.record []
- end
+ before :each do
+ ScratchPad.record []
+ end
+
+ it "breaks a loop" do
+ 3.times do |i|
+ if i == 2
+ @o.rb_iter_break
+ end
+ ScratchPad << i
+ end
+ ScratchPad.recorded.should == [0, 1]
+ end
- it "breaks a loop" do
- 3.times do |i|
- if i == 2
- @o.rb_iter_break
+ it "breaks the inner loop" do
+ 3.times do |i|
+ 3.times do |j|
+ if i == 1
+ @o.rb_iter_break
+ end
+ ScratchPad << [i, j]
+ end
end
- ScratchPad << i
+ ScratchPad.recorded.should == [[0, 0], [0, 1], [0, 2], [2, 0], [2, 1], [2, 2]]
end
- ScratchPad.recorded.should == [0, 1]
end
+ end
+
+ ruby_bug "#7896", "2.0" do
+ describe "rb_iter_break" do
- it "breaks the inner loop" do
- 3.times do |i|
- 3.times do |j|
- if i == 1
+ before :each do
+ ScratchPad.record []
+ end
+
+ it "breaks a loop" do
+ 3.times do |i|
+ if i == 2
@o.rb_iter_break
end
- ScratchPad << [i, j]
+ ScratchPad << i
end
+ ScratchPad.recorded.should == [0, 1]
end
- ScratchPad.recorded.should == [[0, 0], [0, 1], [0, 2], [2, 0], [2, 1], [2, 2]]
- end
+ it "breaks the inner loop" do
+ 3.times do |i|
+ 3.times do |j|
+ if i == 1
+ @o.rb_iter_break
+ end
+ ScratchPad << [i, j]
+ end
+ end
+ ScratchPad.recorded.should == [[0, 0], [0, 1], [0, 2], [2, 0], [2, 1], [2, 2]]
+ end
+ end
end
describe "rb_sourcefile" do

0 comments on commit a842e37

Please sign in to comment.
Something went wrong with that request. Please try again.