mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
5
spec/ruby/core/rational/abs_spec.rb
Normal file
5
spec/ruby/core/rational/abs_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/abs', __FILE__)
|
||||
|
||||
describe "Rational#abs" do
|
||||
it_behaves_like(:rational_abs, :abs)
|
||||
end
|
5
spec/ruby/core/rational/ceil_spec.rb
Normal file
5
spec/ruby/core/rational/ceil_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/ceil', __FILE__)
|
||||
|
||||
describe "Rational#ceil" do
|
||||
it_behaves_like(:rational_ceil, :ceil)
|
||||
end
|
5
spec/ruby/core/rational/coerce_spec.rb
Normal file
5
spec/ruby/core/rational/coerce_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/coerce', __FILE__)
|
||||
|
||||
describe "Rational#coerce" do
|
||||
it_behaves_like(:rational_coerce, :coerce)
|
||||
end
|
21
spec/ruby/core/rational/comparison_spec.rb
Normal file
21
spec/ruby/core/rational/comparison_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../shared/rational/comparison', __FILE__)
|
||||
|
||||
describe "Rational#<=> when passed a Rational object" do
|
||||
it_behaves_like(:rational_cmp_rat, :<=>)
|
||||
end
|
||||
|
||||
describe "Rational#<=> when passed a Integer object" do
|
||||
it_behaves_like(:rational_cmp_int, :<=>)
|
||||
end
|
||||
|
||||
describe "Rational#<=> when passed a Float object" do
|
||||
it_behaves_like(:rational_cmp_float, :<=>)
|
||||
end
|
||||
|
||||
describe "Rational#<=> when passed an Object that responds to #coerce" do
|
||||
it_behaves_like(:rational_cmp_coerce, :<=>)
|
||||
end
|
||||
|
||||
describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do
|
||||
it_behaves_like(:rational_cmp_other, :<=>)
|
||||
end
|
5
spec/ruby/core/rational/denominator_spec.rb
Normal file
5
spec/ruby/core/rational/denominator_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/denominator', __FILE__)
|
||||
|
||||
describe "Rational#denominator" do
|
||||
it_behaves_like(:rational_denominator, :denominator)
|
||||
end
|
17
spec/ruby/core/rational/div_spec.rb
Normal file
17
spec/ruby/core/rational/div_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require File.expand_path('../../../shared/rational/div', __FILE__)
|
||||
|
||||
describe "Rational#div" do
|
||||
it_behaves_like(:rational_div, :div)
|
||||
end
|
||||
|
||||
describe "Rational#div passed a Rational" do
|
||||
it_behaves_like(:rational_div_rat, :div)
|
||||
end
|
||||
|
||||
describe "Rational#div passed an Integer" do
|
||||
it_behaves_like(:rational_div_int, :div)
|
||||
end
|
||||
|
||||
describe "Rational#div passed a Float" do
|
||||
it_behaves_like(:rational_div_float, :div)
|
||||
end
|
17
spec/ruby/core/rational/divide_spec.rb
Normal file
17
spec/ruby/core/rational/divide_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require File.expand_path('../../../shared/rational/divide', __FILE__)
|
||||
|
||||
describe "Rational#/" do
|
||||
it_behaves_like(:rational_divide, :/)
|
||||
end
|
||||
|
||||
describe "Rational#/ when passed an Integer" do
|
||||
it_behaves_like(:rational_divide_int, :/)
|
||||
end
|
||||
|
||||
describe "Rational#/ when passed a Rational" do
|
||||
it_behaves_like(:rational_divide_rat, :/)
|
||||
end
|
||||
|
||||
describe "Rational#/ when passed a Float" do
|
||||
it_behaves_like(:rational_divide_float, :/)
|
||||
end
|
13
spec/ruby/core/rational/divmod_spec.rb
Normal file
13
spec/ruby/core/rational/divmod_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../shared/rational/divmod', __FILE__)
|
||||
|
||||
describe "Rational#divmod when passed a Rational" do
|
||||
it_behaves_like(:rational_divmod_rat, :divmod)
|
||||
end
|
||||
|
||||
describe "Rational#divmod when passed an Integer" do
|
||||
it_behaves_like(:rational_divmod_int, :divmod)
|
||||
end
|
||||
|
||||
describe "Rational#divmod when passed a Float" do
|
||||
it_behaves_like(:rational_divmod_float, :divmod)
|
||||
end
|
17
spec/ruby/core/rational/equal_value_spec.rb
Normal file
17
spec/ruby/core/rational/equal_value_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require File.expand_path('../../../shared/rational/equal_value', __FILE__)
|
||||
|
||||
describe "Rational#==" do
|
||||
it_behaves_like(:rational_equal_value, :==)
|
||||
end
|
||||
|
||||
describe "Rational#== when passed a Rational" do
|
||||
it_behaves_like(:rational_equal_value_rat, :==)
|
||||
end
|
||||
|
||||
describe "Rational#== when passed a Float" do
|
||||
it_behaves_like(:rational_equal_value_float, :==)
|
||||
end
|
||||
|
||||
describe "Rational#== when passed an Integer" do
|
||||
it_behaves_like(:rational_equal_value_int, :==)
|
||||
end
|
5
spec/ruby/core/rational/exponent_spec.rb
Normal file
5
spec/ruby/core/rational/exponent_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/exponent', __FILE__)
|
||||
|
||||
describe "Rational#**" do
|
||||
it_behaves_like(:rational_exponent, :**)
|
||||
end
|
5
spec/ruby/core/rational/fdiv_spec.rb
Normal file
5
spec/ruby/core/rational/fdiv_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/fdiv', __FILE__)
|
||||
|
||||
describe "Rational#fdiv" do
|
||||
it_behaves_like(:rational_fdiv, :fdiv)
|
||||
end
|
5
spec/ruby/core/rational/floor_spec.rb
Normal file
5
spec/ruby/core/rational/floor_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/floor', __FILE__)
|
||||
|
||||
describe "Rational#floor" do
|
||||
it_behaves_like(:rational_floor, :floor)
|
||||
end
|
5
spec/ruby/core/rational/hash_spec.rb
Normal file
5
spec/ruby/core/rational/hash_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/hash', __FILE__)
|
||||
|
||||
describe "Rational#hash" do
|
||||
it_behaves_like(:rational_hash, :hash)
|
||||
end
|
5
spec/ruby/core/rational/inspect_spec.rb
Normal file
5
spec/ruby/core/rational/inspect_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/inspect', __FILE__)
|
||||
|
||||
describe "Rational#inspect" do
|
||||
it_behaves_like(:rational_inspect, :inspect)
|
||||
end
|
9
spec/ruby/core/rational/integer_spec.rb
Normal file
9
spec/ruby/core/rational/integer_spec.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
describe "Rational#integer?" do
|
||||
it "returns false for a rational with a numerator and no denominator" do
|
||||
Rational(20).integer?.should be_false
|
||||
end
|
||||
|
||||
it "returns false for a rational with a numerator and a denominator" do
|
||||
Rational(20,3).integer?.should be_false
|
||||
end
|
||||
end
|
5
spec/ruby/core/rational/magnitude_spec.rb
Normal file
5
spec/ruby/core/rational/magnitude_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/abs', __FILE__)
|
||||
|
||||
describe "Rational#abs" do
|
||||
it_behaves_like(:rational_abs, :magnitude)
|
||||
end
|
11
spec/ruby/core/rational/marshal_dump_spec.rb
Normal file
11
spec/ruby/core/rational/marshal_dump_spec.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Rational#marshal_dump" do
|
||||
it "is a private method" do
|
||||
Rational.should have_private_instance_method(:marshal_dump, false)
|
||||
end
|
||||
|
||||
it "dumps numerator and denominator" do
|
||||
Rational(1, 2).send(:marshal_dump).should == [1, 2]
|
||||
end
|
||||
end
|
5
spec/ruby/core/rational/minus_spec.rb
Normal file
5
spec/ruby/core/rational/minus_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/minus', __FILE__)
|
||||
|
||||
describe "Rational#-" do
|
||||
it_behaves_like(:rational_minus, :-)
|
||||
end
|
5
spec/ruby/core/rational/modulo_spec.rb
Normal file
5
spec/ruby/core/rational/modulo_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/modulo', __FILE__)
|
||||
|
||||
describe "Rational#%" do
|
||||
it_behaves_like(:rational_modulo, :%)
|
||||
end
|
17
spec/ruby/core/rational/multiply_spec.rb
Normal file
17
spec/ruby/core/rational/multiply_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
require File.expand_path('../../../shared/rational/multiply', __FILE__)
|
||||
|
||||
describe "Rational#*" do
|
||||
it_behaves_like(:rational_multiply, :*)
|
||||
end
|
||||
|
||||
describe "Rational#* passed a Rational" do
|
||||
it_behaves_like(:rational_multiply_rat, :*)
|
||||
end
|
||||
|
||||
describe "Rational#* passed a Float" do
|
||||
it_behaves_like(:rational_multiply_float, :*)
|
||||
end
|
||||
|
||||
describe "Rational#* passed an Integer" do
|
||||
it_behaves_like(:rational_multiply_int, :*)
|
||||
end
|
5
spec/ruby/core/rational/numerator_spec.rb
Normal file
5
spec/ruby/core/rational/numerator_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/numerator', __FILE__)
|
||||
|
||||
describe "Rational#numerator" do
|
||||
it_behaves_like(:rational_numerator, :numerator)
|
||||
end
|
16
spec/ruby/core/rational/plus_spec.rb
Normal file
16
spec/ruby/core/rational/plus_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require File.expand_path('../../../shared/rational/plus', __FILE__)
|
||||
|
||||
describe "Rational#+" do
|
||||
it_behaves_like(:rational_plus, :+)
|
||||
end
|
||||
|
||||
describe "Rational#+ with a Rational" do
|
||||
it_behaves_like(:rational_plus_rat, :+)
|
||||
end
|
||||
describe "Rational#+ with a Float" do
|
||||
it_behaves_like(:rational_plus_float, :+)
|
||||
end
|
||||
|
||||
describe "Rational#+ with an Integer" do
|
||||
it_behaves_like(:rational_plus_int, :+)
|
||||
end
|
5
spec/ruby/core/rational/quo_spec.rb
Normal file
5
spec/ruby/core/rational/quo_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/divide', __FILE__)
|
||||
|
||||
describe "Rational#quo" do
|
||||
it_behaves_like(:rational_divide, :quo)
|
||||
end
|
7
spec/ruby/core/rational/rational_spec.rb
Normal file
7
spec/ruby/core/rational/rational_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Rational" do
|
||||
it "includes Comparable" do
|
||||
Rational.include?(Comparable).should == true
|
||||
end
|
||||
end
|
36
spec/ruby/core/rational/rationalize_spec.rb
Normal file
36
spec/ruby/core/rational/rationalize_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe "Rational#rationalize" do
|
||||
it "returns self with no argument" do
|
||||
Rational(12,3).rationalize.should == Rational(12,3)
|
||||
Rational(-45,7).rationalize.should == Rational(-45,7)
|
||||
end
|
||||
|
||||
# FIXME: These specs need reviewing by somebody familiar with the
|
||||
# algorithm used by #rationalize
|
||||
it "simplifies self to the degree specified by a Rational argument" do
|
||||
r = Rational(5404319552844595,18014398509481984)
|
||||
r.rationalize(Rational(1,10)).should == Rational(1,3)
|
||||
r.rationalize(Rational(-1,10)).should == Rational(1,3)
|
||||
|
||||
r = Rational(-5404319552844595,18014398509481984)
|
||||
r.rationalize(Rational(1,10)).should == Rational(-1,3)
|
||||
r.rationalize(Rational(-1,10)).should == Rational(-1,3)
|
||||
|
||||
end
|
||||
|
||||
it "simplifies self to the degree specified by a Float argument" do
|
||||
r = Rational(5404319552844595,18014398509481984)
|
||||
r.rationalize(0.05).should == Rational(1,3)
|
||||
r.rationalize(0.001).should == Rational(3, 10)
|
||||
|
||||
r = Rational(-5404319552844595,18014398509481984)
|
||||
r.rationalize(0.05).should == Rational(-1,3)
|
||||
r.rationalize(0.001).should == Rational(-3,10)
|
||||
end
|
||||
|
||||
it "raises ArgumentError when passed more than one argument" do
|
||||
lambda { Rational(1,1).rationalize(0.1, 0.1) }.should raise_error(ArgumentError)
|
||||
lambda { Rational(1,1).rationalize(0.1, 0.1, 2) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
5
spec/ruby/core/rational/remainder_spec.rb
Normal file
5
spec/ruby/core/rational/remainder_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/remainder', __FILE__)
|
||||
|
||||
describe "Rational#remainder" do
|
||||
it_behaves_like(:rational_remainder, :remainder)
|
||||
end
|
5
spec/ruby/core/rational/round_spec.rb
Normal file
5
spec/ruby/core/rational/round_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/round', __FILE__)
|
||||
|
||||
describe "Rational#round" do
|
||||
it_behaves_like(:rational_round, :round)
|
||||
end
|
5
spec/ruby/core/rational/to_f_spec.rb
Normal file
5
spec/ruby/core/rational/to_f_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/to_f', __FILE__)
|
||||
|
||||
describe "Rational#to_f" do
|
||||
it_behaves_like(:rational_to_f, :to_f)
|
||||
end
|
5
spec/ruby/core/rational/to_i_spec.rb
Normal file
5
spec/ruby/core/rational/to_i_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/to_i', __FILE__)
|
||||
|
||||
describe "Rational#to_i" do
|
||||
it_behaves_like(:rational_to_i, :to_i)
|
||||
end
|
20
spec/ruby/core/rational/to_r_spec.rb
Normal file
20
spec/ruby/core/rational/to_r_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require File.expand_path('../../../shared/rational/to_r', __FILE__)
|
||||
|
||||
describe "Rational#to_r" do
|
||||
it_behaves_like(:rational_to_r, :to_r)
|
||||
|
||||
it "raises TypeError trying to convert BasicObject" do
|
||||
obj = BasicObject.new
|
||||
lambda { Rational(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "works when a BasicObject has to_r" do
|
||||
obj = BasicObject.new; def obj.to_r; 1 / 2.to_r end
|
||||
Rational(obj).should == Rational('1/2')
|
||||
end
|
||||
|
||||
it "fails when a BasicObject's to_r does not return a Rational" do
|
||||
obj = BasicObject.new; def obj.to_r; 1 end
|
||||
lambda { Rational(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
5
spec/ruby/core/rational/to_s_spec.rb
Normal file
5
spec/ruby/core/rational/to_s_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/to_s', __FILE__)
|
||||
|
||||
describe "Rational#to_s" do
|
||||
it_behaves_like(:rational_to_s, :to_s)
|
||||
end
|
5
spec/ruby/core/rational/truncate_spec.rb
Normal file
5
spec/ruby/core/rational/truncate_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../shared/rational/truncate', __FILE__)
|
||||
|
||||
describe "Rational#truncate" do
|
||||
it_behaves_like(:rational_truncate, :truncate)
|
||||
end
|
13
spec/ruby/core/rational/zero_spec.rb
Normal file
13
spec/ruby/core/rational/zero_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
describe "Rational#zero?" do
|
||||
it "returns true if the numerator is 0" do
|
||||
Rational(0,26).zero?.should be_true
|
||||
end
|
||||
|
||||
it "returns true if the numerator is 0.0" do
|
||||
Rational(0.0,26).zero?.should be_true
|
||||
end
|
||||
|
||||
it "returns false if the numerator isn't 0" do
|
||||
Rational(26).zero?.should be_false
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue