git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-09-28 09:19:59 +00:00
Родитель c555bd7f01
Коммит 52d2636f3e
18 изменённых файлов: 134 добавлений и 26 удалений

Просмотреть файл

@ -1,18 +1,29 @@
--- ---
version: "{build}" version: "{build}"
clone_depth: 5 clone_depth: 5
init:
# To avoid duplicated executables in PATH, see https://github.com/ruby/spec/pull/468
- set PATH=C:\ruby%RUBY_VERSION%\bin;C:\Program Files\7-Zip;C:\Program Files\AppVeyor\BuildAgent;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Program Files;C:\Windows
# Loads trunk build and updates MSYS2 / MinGW to most recent gcc compiler
- if %ruby_version%==_trunk (
appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z &
7z x C:\ruby_trunk.7z -oC:\ruby_trunk & C:\ruby_trunk\trunk_msys2.cmd)
environment: environment:
matrix: matrix:
- RUBY_VERSION: 23-x64 - RUBY_VERSION: 23-x64
- RUBY_VERSION: 24-x64
- RUBY_VERSION: _trunk # So the folder name is ruby_trunk
install: install:
- SET PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
- ruby --version
- call "C:\Ruby23-x64\DevKit\devkitvars.bat"
- git clone https://github.com/ruby/mspec.git ../mspec - git clone https://github.com/ruby/mspec.git ../mspec
build: off build: off
test_script: test_script:
- SET CHECK_LEAKS=true - SET CHECK_LEAKS=true
- ../mspec/bin/mspec -ff - ../mspec/bin/mspec -rdevkit -ff
on_finish:
- ruby -v
matrix:
allow_failures:
- ruby_version: _trunk
branches: branches:
only: only:
- master - master

Просмотреть файл

@ -6,8 +6,7 @@ describe "The -v command line option" do
describe "when used alone" do describe "when used alone" do
it "prints version and ends" do it "prints version and ends" do
version = ruby_exe(nil, args: '--version') ruby_exe(nil, args: '-v').include?(RUBY_DESCRIPTION).should == true
ruby_exe(nil, args: '-v').should == version
end end
end end
end end

Просмотреть файл

@ -108,6 +108,7 @@ describe "IO.select when passed nil for timeout" do
end end
Thread.pass while t.status && t.status != "sleep" Thread.pass while t.status && t.status != "sleep"
t.join unless t.status
t.status.should == "sleep" t.status.should == "sleep"
t.kill t.kill
t.join t.join

Просмотреть файл

@ -25,4 +25,11 @@ describe "String#include? with String" do
lambda { "hello".include?('h'.ord) }.should raise_error(TypeError) lambda { "hello".include?('h'.ord) }.should raise_error(TypeError)
lambda { "hello".include?(mock('x')) }.should raise_error(TypeError) lambda { "hello".include?(mock('x')) }.should raise_error(TypeError)
end end
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
pat = "".encode Encoding::EUC_JP
lambda do
"あれ".include?(pat)
end.should raise_error(Encoding::CompatibilityError)
end
end end

Просмотреть файл

@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
require 'date' require 'date'
describe "Date#day" do describe "Date#day" do
it "needs to be reviewed for spec completeness" it "returns the day" do
d = Date.new(2000, 7, 1).day
d.should == 1
end
end end

Просмотреть файл

@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
require 'date' require 'date'
describe "Date#month" do describe "Date#month" do
it "needs to be reviewed for spec completeness" it "returns the month" do
m = Date.new(2000, 7, 1).month
m.should == 7
end
end end

Просмотреть файл

@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#next_month" do
it "returns the next month" do
d = Date.new(2000, 7, 1).next_month
d.should == Date.new(2000, 8, 1)
end
it "returns three months later" do
d = Date.new(2000, 7, 1).next_month(3)
d.should == Date.new(2000, 10, 1)
end
end

Просмотреть файл

@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#prev_day" do
it "returns previous day" do
d = Date.new(2000, 7, 2).prev_day
d.should == Date.new(2000, 7, 1)
end
it "returns three days ago" do
d = Date.new(2000, 7, 4).prev_day(3)
d.should == Date.new(2000, 7, 1)
end
end

Просмотреть файл

@ -0,0 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
describe "Date#prev_month" do
it "returns previous month" do
d = Date.new(2000, 9, 1).prev_month
d.should == Date.new(2000, 8, 1)
end
it "returns three months ago" do
d = Date.new(2000, 10, 1).prev_month(3)
d.should == Date.new(2000, 7, 1)
end
end

Просмотреть файл

@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
require 'date' require 'date'
describe "Date#year" do describe "Date#year" do
it "needs to be reviewed for spec completeness" it "returns the year" do
y = Date.new(2000, 7, 1).year
y.should == 2000
end
end end

Просмотреть файл

@ -10,7 +10,7 @@ with_feature :fiber_library do
# We can always transfer to the root Fiber; it will never die # We can always transfer to the root Fiber; it will never die
5.times do 5.times do
root.transfer.should be_nil root.transfer.should be_nil
root.alive?.should_not be_false #Workaround for bug #1547 root.alive?.should be_true
end end
end end
@ -19,39 +19,31 @@ with_feature :fiber_library do
this = Fiber.current this = Fiber.current
this.should be_an_instance_of(Fiber) this.should be_an_instance_of(Fiber)
this.should == fiber this.should == fiber
this.alive?.should_not be_false # Workaround for bug #1547 this.alive?.should be_true
end end
fiber.resume fiber.resume
end end
it "returns the current Fiber when called from a Fiber that transferred to another" do it "returns the current Fiber when called from a Fiber that transferred to another" do
states = [] states = []
fiber = Fiber.new do fiber = Fiber.new do
states << :fiber states << :fiber
this = Fiber.current this = Fiber.current
this.should be_an_instance_of(Fiber) this.should be_an_instance_of(Fiber)
this.should === fiber this.should == fiber
this.alive?.should_not be_false # Workaround for bug #1547 this.alive?.should be_true
end end
fiber2 = Fiber.new do fiber2 = Fiber.new do
states << :fiber2 states << :fiber2
fiber.transfer fiber.transfer
this = Fiber.current flunk
this.should be_an_instance_of(Fiber)
this.should === fiber2
this.alive?.should_not be_false # Workaround for bug #1547
end end
fiber3 = Fiber.new do fiber3 = Fiber.new do
states << :fiber3 states << :fiber3
fiber2.transfer fiber2.transfer
this = Fiber.current flunk
this.should be_an_instance_of(Fiber)
this.should === fiber3
this.alive?.should_not be_false # Workaround for bug #1547
fiber2.transfer
end end
fiber3.resume fiber3.resume

Просмотреть файл

@ -7,9 +7,15 @@ describe "SortedSet#add" do
it "takes only values which responds <=>" do it "takes only values which responds <=>" do
obj = mock('no_comparison_operator') obj = mock('no_comparison_operator')
obj.should_receive(:respond_to?).with(:<=>).and_return(false) obj.stub!(:respond_to?).with(:<=>).and_return(false)
lambda { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError) lambda { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
end end
it "raises on incompatible <=> comparison" do
# Use #to_a here as elements are sorted only when needed.
# Therefore the <=> incompatibility is only noticed on sorting.
lambda { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
end
end end
describe "SortedSet#add?" do describe "SortedSet#add?" do

Просмотреть файл

@ -21,4 +21,10 @@ describe "SortedSet#initialize" do
s.should include(4) s.should include(4)
s.should include(9) s.should include(9)
end end
it "raises on incompatible <=> comparison" do
# Use #to_a here as elements are sorted only when needed.
# Therefore the <=> incompatibility is only noticed on sorting.
lambda { SortedSet.new(['00', nil]).to_a }.should raise_error(ArgumentError)
end
end end

Просмотреть файл

@ -2,7 +2,16 @@ require File.expand_path('../../../../spec_helper', __FILE__)
require 'set' require 'set'
describe "SortedSet#to_a" do describe "SortedSet#to_a" do
it "returns an array containing elements of self" do it "returns an array containing elements" do
SortedSet[1, 2, 3].to_a.sort.should == [1, 2, 3] set = SortedSet.new [1, 2, 3]
set.to_a.should == [1, 2, 3]
end
it "returns a sorted array containing elements" do
set = SortedSet[2, 3, 1]
set.to_a.should == [1, 2, 3]
set = SortedSet.new [5, 6, 4, 4]
set.to_a.should == [4, 5, 6]
end end
end end

Просмотреть файл

@ -152,6 +152,12 @@ static VALUE module_specs_rbclass2name(VALUE self, VALUE klass) {
} }
#endif #endif
#ifdef HAVE_RB_MOD_ANCESTORS
static VALUE module_specs_rb_mod_ancestors(VALUE self, VALUE klass) {
return rb_mod_ancestors(klass);
}
#endif
void Init_module_spec(void) { void Init_module_spec(void) {
VALUE cls; VALUE cls;
@ -245,6 +251,10 @@ void Init_module_spec(void) {
#ifdef HAVE_RB_CLASS2NAME #ifdef HAVE_RB_CLASS2NAME
rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1); rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1);
#endif #endif
#ifdef HAVE_RB_MOD_ANCESTORS
rb_define_method(cls, "rb_mod_ancestors", module_specs_rb_mod_ancestors, 1);
#endif
} }
#ifdef __cplusplus #ifdef __cplusplus

Просмотреть файл

@ -401,6 +401,7 @@
#define HAVE_RB_DEFINE_PRIVATE_METHOD 1 #define HAVE_RB_DEFINE_PRIVATE_METHOD 1
#define HAVE_RB_DEFINE_PROTECTED_METHOD 1 #define HAVE_RB_DEFINE_PROTECTED_METHOD 1
#define HAVE_RB_DEFINE_SINGLETON_METHOD 1 #define HAVE_RB_DEFINE_SINGLETON_METHOD 1
#define HAVE_RB_MOD_ANCESTORS 1
#define HAVE_RB_UNDEF 1 #define HAVE_RB_UNDEF 1
#define HAVE_RB_UNDEF_METHOD 1 #define HAVE_RB_UNDEF_METHOD 1

Просмотреть файл

@ -339,4 +339,14 @@ describe "CApiModule" do
@m.rb_class2name(CApiModuleSpecs::M).should == "CApiModuleSpecs::M" @m.rb_class2name(CApiModuleSpecs::M).should == "CApiModuleSpecs::M"
end end
end end
describe "rb_mod_ancestors" do
it "returns an array of ancestors" do
one = Module.new
two = Module.new do
include one
end
@m.rb_mod_ancestors(two).should == [two, one]
end
end
end end

Просмотреть файл

@ -4,6 +4,11 @@ describe :fiber_resume, shared: true do
fiber.send(@method).should == :fiber fiber.send(@method).should == :fiber
end end
it "raises a FiberError if the Fiber tries to resume itself" do
fiber = Fiber.new { fiber.resume }
-> { fiber.resume }.should raise_error(FiberError, /double resume/)
end
it "raises a FiberError if invoked from a different Thread" do it "raises a FiberError if invoked from a different Thread" do
fiber = Fiber.new { } fiber = Fiber.new { }
lambda do lambda do