diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-28 09:19:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-28 09:19:59 +0000 |
commit | 52d2636f3e7658f76136310359c2ba00e613d2bd (patch) | |
tree | 523a193924876ba20fe00debc3f45765fb21bd79 /spec | |
parent | c555bd7f01c531af8d33ed494b278a765381afd9 (diff) | |
download | ruby-52d2636f3e7658f76136310359c2ba00e613d2bd.tar.gz |
Update to ruby/spec@691755d
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ruby/appveyor.yml | 19 | ||||
-rw-r--r-- | spec/ruby/command_line/dash_v_spec.rb | 3 | ||||
-rw-r--r-- | spec/ruby/core/io/select_spec.rb | 1 | ||||
-rw-r--r-- | spec/ruby/core/string/include_spec.rb | 7 | ||||
-rw-r--r-- | spec/ruby/library/date/day_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/date/month_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/date/next_month_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/prev_day_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/prev_month_spec.rb | 14 | ||||
-rw-r--r-- | spec/ruby/library/date/year_spec.rb | 5 | ||||
-rw-r--r-- | spec/ruby/library/fiber/current_spec.rb | 20 | ||||
-rw-r--r-- | spec/ruby/library/set/sortedset/add_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/library/set/sortedset/initialize_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/library/set/sortedset/to_a_spec.rb | 13 | ||||
-rw-r--r-- | spec/ruby/optional/capi/ext/module_spec.c | 10 | ||||
-rw-r--r-- | spec/ruby/optional/capi/ext/rubyspec.h | 1 | ||||
-rw-r--r-- | spec/ruby/optional/capi/module_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/shared/fiber/resume.rb | 5 |
18 files changed, 134 insertions, 26 deletions
diff --git a/spec/ruby/appveyor.yml b/spec/ruby/appveyor.yml index 544bea7d1b..8ee5abd8b4 100644 --- a/spec/ruby/appveyor.yml +++ b/spec/ruby/appveyor.yml @@ -1,18 +1,29 @@ --- version: "{build}" 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: matrix: - RUBY_VERSION: 23-x64 + - RUBY_VERSION: 24-x64 + - RUBY_VERSION: _trunk # So the folder name is ruby_trunk 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 build: off test_script: - SET CHECK_LEAKS=true - - ../mspec/bin/mspec -ff + - ../mspec/bin/mspec -rdevkit -ff +on_finish: + - ruby -v +matrix: + allow_failures: + - ruby_version: _trunk branches: only: - master diff --git a/spec/ruby/command_line/dash_v_spec.rb b/spec/ruby/command_line/dash_v_spec.rb index a7abd9de82..2ee9099419 100644 --- a/spec/ruby/command_line/dash_v_spec.rb +++ b/spec/ruby/command_line/dash_v_spec.rb @@ -6,8 +6,7 @@ describe "The -v command line option" do describe "when used alone" do it "prints version and ends" do - version = ruby_exe(nil, args: '--version') - ruby_exe(nil, args: '-v').should == version + ruby_exe(nil, args: '-v').include?(RUBY_DESCRIPTION).should == true end end end diff --git a/spec/ruby/core/io/select_spec.rb b/spec/ruby/core/io/select_spec.rb index aa1199c03b..eba8519e5b 100644 --- a/spec/ruby/core/io/select_spec.rb +++ b/spec/ruby/core/io/select_spec.rb @@ -108,6 +108,7 @@ describe "IO.select when passed nil for timeout" do end Thread.pass while t.status && t.status != "sleep" + t.join unless t.status t.status.should == "sleep" t.kill t.join diff --git a/spec/ruby/core/string/include_spec.rb b/spec/ruby/core/string/include_spec.rb index 8da12a9862..d7780de602 100644 --- a/spec/ruby/core/string/include_spec.rb +++ b/spec/ruby/core/string/include_spec.rb @@ -25,4 +25,11 @@ describe "String#include? with String" do lambda { "hello".include?('h'.ord) }.should raise_error(TypeError) lambda { "hello".include?(mock('x')) }.should raise_error(TypeError) 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 diff --git a/spec/ruby/library/date/day_spec.rb b/spec/ruby/library/date/day_spec.rb index 7dfca4d77c..d3561d802d 100644 --- a/spec/ruby/library/date/day_spec.rb +++ b/spec/ruby/library/date/day_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' 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 diff --git a/spec/ruby/library/date/month_spec.rb b/spec/ruby/library/date/month_spec.rb index 7a98f572b6..ea35430d6b 100644 --- a/spec/ruby/library/date/month_spec.rb +++ b/spec/ruby/library/date/month_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' 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 diff --git a/spec/ruby/library/date/next_month_spec.rb b/spec/ruby/library/date/next_month_spec.rb new file mode 100644 index 0000000000..22699a39a5 --- /dev/null +++ b/spec/ruby/library/date/next_month_spec.rb @@ -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 diff --git a/spec/ruby/library/date/prev_day_spec.rb b/spec/ruby/library/date/prev_day_spec.rb new file mode 100644 index 0000000000..8a42824154 --- /dev/null +++ b/spec/ruby/library/date/prev_day_spec.rb @@ -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 diff --git a/spec/ruby/library/date/prev_month_spec.rb b/spec/ruby/library/date/prev_month_spec.rb new file mode 100644 index 0000000000..eaf7f67ee0 --- /dev/null +++ b/spec/ruby/library/date/prev_month_spec.rb @@ -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 diff --git a/spec/ruby/library/date/year_spec.rb b/spec/ruby/library/date/year_spec.rb index cca95dbe2a..4720ddcd9a 100644 --- a/spec/ruby/library/date/year_spec.rb +++ b/spec/ruby/library/date/year_spec.rb @@ -2,5 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) require 'date' 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 diff --git a/spec/ruby/library/fiber/current_spec.rb b/spec/ruby/library/fiber/current_spec.rb index 48345fb7cf..fd68cd52ea 100644 --- a/spec/ruby/library/fiber/current_spec.rb +++ b/spec/ruby/library/fiber/current_spec.rb @@ -10,7 +10,7 @@ with_feature :fiber_library do # We can always transfer to the root Fiber; it will never die 5.times do root.transfer.should be_nil - root.alive?.should_not be_false #Workaround for bug #1547 + root.alive?.should be_true end end @@ -19,39 +19,31 @@ with_feature :fiber_library do this = Fiber.current this.should be_an_instance_of(Fiber) this.should == fiber - this.alive?.should_not be_false # Workaround for bug #1547 + this.alive?.should be_true end fiber.resume end it "returns the current Fiber when called from a Fiber that transferred to another" do - states = [] fiber = Fiber.new do states << :fiber this = Fiber.current this.should be_an_instance_of(Fiber) - this.should === fiber - this.alive?.should_not be_false # Workaround for bug #1547 + this.should == fiber + this.alive?.should be_true end fiber2 = Fiber.new do states << :fiber2 fiber.transfer - this = Fiber.current - this.should be_an_instance_of(Fiber) - this.should === fiber2 - this.alive?.should_not be_false # Workaround for bug #1547 + flunk end fiber3 = Fiber.new do states << :fiber3 fiber2.transfer - this = Fiber.current - this.should be_an_instance_of(Fiber) - this.should === fiber3 - this.alive?.should_not be_false # Workaround for bug #1547 - fiber2.transfer + flunk end fiber3.resume diff --git a/spec/ruby/library/set/sortedset/add_spec.rb b/spec/ruby/library/set/sortedset/add_spec.rb index bdc5c077d8..df291561a8 100644 --- a/spec/ruby/library/set/sortedset/add_spec.rb +++ b/spec/ruby/library/set/sortedset/add_spec.rb @@ -7,9 +7,15 @@ describe "SortedSet#add" do it "takes only values which responds <=>" do 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) 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 describe "SortedSet#add?" do diff --git a/spec/ruby/library/set/sortedset/initialize_spec.rb b/spec/ruby/library/set/sortedset/initialize_spec.rb index 04ad908667..77ee23e851 100644 --- a/spec/ruby/library/set/sortedset/initialize_spec.rb +++ b/spec/ruby/library/set/sortedset/initialize_spec.rb @@ -21,4 +21,10 @@ describe "SortedSet#initialize" do s.should include(4) s.should include(9) 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 diff --git a/spec/ruby/library/set/sortedset/to_a_spec.rb b/spec/ruby/library/set/sortedset/to_a_spec.rb index f288cfb9d2..77deb17731 100644 --- a/spec/ruby/library/set/sortedset/to_a_spec.rb +++ b/spec/ruby/library/set/sortedset/to_a_spec.rb @@ -2,7 +2,16 @@ require File.expand_path('../../../../spec_helper', __FILE__) require 'set' describe "SortedSet#to_a" do - it "returns an array containing elements of self" do - SortedSet[1, 2, 3].to_a.sort.should == [1, 2, 3] + it "returns an array containing elements" do + 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 diff --git a/spec/ruby/optional/capi/ext/module_spec.c b/spec/ruby/optional/capi/ext/module_spec.c index 275bc4da32..e408404a09 100644 --- a/spec/ruby/optional/capi/ext/module_spec.c +++ b/spec/ruby/optional/capi/ext/module_spec.c @@ -152,6 +152,12 @@ static VALUE module_specs_rbclass2name(VALUE self, VALUE klass) { } #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) { VALUE cls; @@ -245,6 +251,10 @@ void Init_module_spec(void) { #ifdef HAVE_RB_CLASS2NAME rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1); #endif + +#ifdef HAVE_RB_MOD_ANCESTORS + rb_define_method(cls, "rb_mod_ancestors", module_specs_rb_mod_ancestors, 1); +#endif } #ifdef __cplusplus diff --git a/spec/ruby/optional/capi/ext/rubyspec.h b/spec/ruby/optional/capi/ext/rubyspec.h index 8866e39af4..12c71d98b0 100644 --- a/spec/ruby/optional/capi/ext/rubyspec.h +++ b/spec/ruby/optional/capi/ext/rubyspec.h @@ -401,6 +401,7 @@ #define HAVE_RB_DEFINE_PRIVATE_METHOD 1 #define HAVE_RB_DEFINE_PROTECTED_METHOD 1 #define HAVE_RB_DEFINE_SINGLETON_METHOD 1 +#define HAVE_RB_MOD_ANCESTORS 1 #define HAVE_RB_UNDEF 1 #define HAVE_RB_UNDEF_METHOD 1 diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb index 23fb674f0e..b3aeae4011 100644 --- a/spec/ruby/optional/capi/module_spec.rb +++ b/spec/ruby/optional/capi/module_spec.rb @@ -339,4 +339,14 @@ describe "CApiModule" do @m.rb_class2name(CApiModuleSpecs::M).should == "CApiModuleSpecs::M" 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 diff --git a/spec/ruby/shared/fiber/resume.rb b/spec/ruby/shared/fiber/resume.rb index 304cd88de1..a680839a4b 100644 --- a/spec/ruby/shared/fiber/resume.rb +++ b/spec/ruby/shared/fiber/resume.rb @@ -4,6 +4,11 @@ describe :fiber_resume, shared: true do fiber.send(@method).should == :fiber 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 fiber = Fiber.new { } lambda do |