This commit is contained in:
Andrew Konchin 2025-01-06 20:28:22 +02:00 committed by Benoit Daloze
parent 36d5e2d8f7
commit 10917c5cc0
Notes: git 2025-01-07 11:31:15 +00:00
154 changed files with 1380 additions and 1637 deletions

View File

@ -113,9 +113,9 @@ Also `have_constant`, `have_private_instance_method`, `have_singleton_method`, e
}
```
##### should_not raise_error
##### `should_not raise_error`
**To avoid!** Instead, use an expectation testing what the code in the lambda does.
**Avoid this!** Instead, use an expectation testing what the code in the lambda does.
If an exception is raised, it will fail the example anyway.
```ruby

View File

@ -44,7 +44,7 @@ For *testing* the development version of a Ruby implementation, one should alway
Also, this repository doesn't always contain the latest spec changes from MRI (it's synchronized monthly), and does not contain tags (specs marked as failing on that Ruby implementation).
Running specs on a Ruby implementation can be done with:
```
```console
$ cd ruby_implementation/spec/ruby
# Add ../ruby_implementation/bin in PATH, or pass -t /path/to/bin/ruby
$ ../mspec/bin/mspec

View File

@ -124,3 +124,96 @@ describe "Dir.chdir" do
Dir.pwd.should == @original
end
end
ruby_version_is '3.3' do
describe "Dir#chdir" do
before :all do
DirSpecs.create_mock_dirs
end
after :all do
DirSpecs.delete_mock_dirs
end
before :each do
@original = Dir.pwd
end
after :each do
Dir.chdir(@original)
end
it "changes the current working directory to self" do
dir = Dir.new(DirSpecs.mock_dir)
dir.chdir
Dir.pwd.should == DirSpecs.mock_dir
ensure
dir.close
end
it "changes the current working directory to self for duration of the block when a block is given" do
dir = Dir.new(DirSpecs.mock_dir)
pwd_in_block = nil
dir.chdir { pwd_in_block = Dir.pwd }
pwd_in_block.should == DirSpecs.mock_dir
Dir.pwd.should == @original
ensure
dir.close
end
it "returns 0 when successfully changing directory" do
dir = Dir.new(DirSpecs.mock_dir)
dir.chdir.should == 0
ensure
dir.close
end
it "returns the value of the block when a block is given" do
dir = Dir.new(DirSpecs.mock_dir)
dir.chdir { :block_value }.should == :block_value
ensure
dir.close
end
it "raises an Errno::ENOENT if the original directory no longer exists" do
dir_name1 = tmp('/testdir1')
dir_name2 = tmp('/testdir2')
File.should_not.exist?(dir_name1)
File.should_not.exist?(dir_name2)
Dir.mkdir dir_name1
Dir.mkdir dir_name2
dir1 = Dir.new(dir_name1)
begin
-> {
dir1.chdir do
Dir.chdir(dir_name2) { Dir.unlink dir_name1 }
end
}.should raise_error(Errno::ENOENT)
ensure
Dir.unlink dir_name1 if File.exist?(dir_name1)
Dir.unlink dir_name2 if File.exist?(dir_name2)
end
ensure
dir1.close
end
it "always returns to the original directory when given a block" do
dir = Dir.new(DirSpecs.mock_dir)
begin
dir.chdir do
raise StandardError, "something bad happened"
end
rescue StandardError
end
Dir.pwd.should == @original
ensure
dir.close
end
end
end

View File

@ -11,9 +11,43 @@ describe "Dir#close" do
it "does not raise an IOError even if the Dir instance is closed" do
dir = Dir.open DirSpecs.mock_dir
dir.close
-> {
dir.close
}.should_not raise_error(IOError)
dir.close.should == nil
dir.close.should == nil
guard -> { dir.respond_to? :fileno } do
-> { dir.fileno }.should raise_error(IOError, /closed directory/)
end
end
it "returns nil" do
dir = Dir.open DirSpecs.mock_dir
dir.close.should == nil
end
ruby_version_is '3.3'...'3.4' do
guard -> { Dir.respond_to? :for_fd } do
it "does not raise an error even if the file descriptor is closed with another Dir instance" do
dir = Dir.open DirSpecs.mock_dir
dir_new = Dir.for_fd(dir.fileno)
dir.close
dir_new.close
-> { dir.fileno }.should raise_error(IOError, /closed directory/)
-> { dir_new.fileno }.should raise_error(IOError, /closed directory/)
end
end
end
ruby_version_is '3.4' do
guard -> { Dir.respond_to? :for_fd } do
it "raises an error if the file descriptor is closed with another Dir instance" do
dir = Dir.open DirSpecs.mock_dir
dir_new = Dir.for_fd(dir.fileno)
dir.close
-> { dir_new.close }.should raise_error(Errno::EBADF, 'Bad file descriptor - closedir')
end
end
end
end

View File

@ -13,46 +13,51 @@ ruby_version_is '3.3' do
end
before :each do
@dirs = [Dir.new('.')]
@original = @dirs.first.fileno
@original = Dir.pwd
end
after :each do
Dir.fchdir(@original)
@dirs.each(&:close)
Dir.chdir(@original)
end
it "changes to the specified directory" do
it "changes the current working directory to the directory specified by the integer file descriptor" do
dir = Dir.new(DirSpecs.mock_dir)
@dirs << dir
Dir.fchdir dir.fileno
Dir.pwd.should == DirSpecs.mock_dir
ensure
dir.close
end
it "returns 0 when successfully changing directory" do
Dir.fchdir(@original).should == 0
dir = Dir.new(DirSpecs.mock_dir)
Dir.fchdir(dir.fileno).should == 0
ensure
dir.close
end
it "returns the value of the block when a block is given" do
Dir.fchdir(@original) { :block_value }.should == :block_value
dir = Dir.new(DirSpecs.mock_dir)
Dir.fchdir(dir.fileno) { :block_value }.should == :block_value
ensure
dir.close
end
it "changes to the specified directory for the duration of the block" do
pwd = Dir.pwd
dir = Dir.new(DirSpecs.mock_dir)
@dirs << dir
Dir.fchdir(dir.fileno) { Dir.pwd }.should == DirSpecs.mock_dir
Dir.pwd.should == pwd
Dir.pwd.should == @original
ensure
dir.close
end
it "raises a SystemCallError if the file descriptor given is not valid" do
-> { Dir.fchdir(-1) }.should raise_error(SystemCallError)
-> { Dir.fchdir(-1) { } }.should raise_error(SystemCallError)
-> { Dir.fchdir(-1) }.should raise_error(SystemCallError, "Bad file descriptor - fchdir")
-> { Dir.fchdir(-1) { } }.should raise_error(SystemCallError, "Bad file descriptor - fchdir")
end
it "raises a SystemCallError if the file descriptor given is not for a directory" do
-> { Dir.fchdir $stdout.fileno }.should raise_error(SystemCallError)
-> { Dir.fchdir($stdout.fileno) { } }.should raise_error(SystemCallError)
-> { Dir.fchdir $stdout.fileno }.should raise_error(SystemCallError, /(Not a directory|Invalid argument) - fchdir/)
-> { Dir.fchdir($stdout.fileno) { } }.should raise_error(SystemCallError, /(Not a directory|Invalid argument) - fchdir/)
end
end
end

View File

@ -0,0 +1,77 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
ruby_version_is '3.3' do
guard -> { Dir.respond_to? :for_fd } do
describe "Dir.for_fd" do
before :all do
DirSpecs.create_mock_dirs
end
after :all do
DirSpecs.delete_mock_dirs
end
before :each do
@original = Dir.pwd
end
after :each do
Dir.chdir(@original)
end
it "returns a new Dir object representing the directory specified by the given integer directory file descriptor" do
dir = Dir.new(DirSpecs.mock_dir)
dir_new = Dir.for_fd(dir.fileno)
dir_new.should.instance_of?(Dir)
dir_new.children.should == dir.children
dir_new.fileno.should == dir.fileno
ensure
dir.close
end
it "returns a new Dir object without associated path" do
dir = Dir.new(DirSpecs.mock_dir)
dir_new = Dir.for_fd(dir.fileno)
dir_new.path.should == nil
ensure
dir.close
end
it "calls #to_int to convert a value to an Integer" do
dir = Dir.new(DirSpecs.mock_dir)
obj = Object.new
obj.singleton_class.define_method(:to_int) { dir.fileno }
dir_new = Dir.for_fd(obj)
dir_new.fileno.should == dir.fileno
ensure
dir.close
end
it "raises TypeError when value cannot be converted to Integer" do
-> {
Dir.for_fd(nil)
}.should raise_error(TypeError, "no implicit conversion from nil to integer")
end
it "raises a SystemCallError if the file descriptor given is not valid" do
-> { Dir.for_fd(-1) }.should raise_error(SystemCallError, "Bad file descriptor - fdopendir")
end
it "raises a SystemCallError if the file descriptor given is not for a directory" do
-> { Dir.for_fd $stdout.fileno }.should raise_error(SystemCallError, "Not a directory - fdopendir")
end
end
end
guard_not -> { Dir.respond_to? :for_fd } do
describe "Dir.for_fd" do
it "raises NotImplementedError" do
-> { Dir.for_fd 1 }.should raise_error(NotImplementedError)
end
end
end
end

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/with_index'
require_relative 'shared/with_index'
require_relative '../enumerable/shared/enumeratorized'
describe "Enumerator#each_with_index" do

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/with_object'
require_relative 'shared/with_object'
describe "Enumerator#each_with_object" do
it_behaves_like :enum_with_object, :each_with_object

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/enum_for'
require_relative 'shared/enum_for'
describe "Enumerator#enum_for" do
it_behaves_like :enum_for, :enum_for

View File

@ -1,8 +1,8 @@
require_relative '../../spec_helper'
require_relative '../../../spec_helper'
describe :enum_with_index, shared: true do
require_relative '../../fixtures/enumerator/classes'
require_relative '../fixtures/classes'
before :each do
@origin = [1, 2, 3, 4]

View File

@ -1,4 +1,4 @@
require_relative '../../spec_helper'
require_relative '../../../spec_helper'
describe :enum_with_object, shared: true do
before :each do

View File

@ -1,6 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/enum_for'
require_relative 'shared/enum_for'
describe "Enumerator#to_enum" do
it_behaves_like :enum_for, :enum_for
it_behaves_like :enum_for, :to_enum
end

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/with_index'
require_relative 'shared/with_index'
require_relative '../enumerable/shared/enumeratorized'
describe "Enumerator#with_index" do

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/enumerator/with_object'
require_relative 'shared/with_object'
describe "Enumerator#with_object" do
it_behaves_like :enum_with_object, :with_object

View File

@ -92,7 +92,7 @@ ruby_version_is "3.2" do
end
end
ruby_bug "#20978", "3.2.3"..."3.4" do
ruby_bug "#20978", "3.2"..."3.4" do
it "can use keys as strings" do
key = Object.new
def key.to_str; "Foo"; end

View File

@ -4,7 +4,7 @@ require_relative '../../../spec_helper'
"FNM_DOTMATCH", "FNM_EXTGLOB", "FNM_NOESCAPE", "FNM_PATHNAME",
"FNM_SYSCASE", "LOCK_EX", "LOCK_NB", "LOCK_SH",
"LOCK_UN", "NONBLOCK", "RDONLY",
"RDWR", "TRUNC", "WRONLY"].each do |const|
"RDWR", "TRUNC", "WRONLY", "SHARE_DELETE"].each do |const|
describe "File::Constants::#{const}" do
it "is defined" do
File::Constants.const_defined?(const).should be_true

View File

@ -1,6 +1,150 @@
require_relative '../../spec_helper'
require_relative '../../shared/rational/Rational'
require_relative '../rational/fixtures/rational'
describe "Kernel.Rational" do
it_behaves_like :kernel_Rational, :Rational
describe "passed Integer" do
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
it "returns a new Rational number with 1 as the denominator" do
Rational(1).should eql(Rational(1, 1))
Rational(-3).should eql(Rational(-3, 1))
Rational(bignum_value).should eql(Rational(bignum_value, 1))
end
end
end
describe "passed two integers" do
it "returns a new Rational number" do
rat = Rational(1, 2)
rat.numerator.should == 1
rat.denominator.should == 2
rat.should be_an_instance_of(Rational)
rat = Rational(-3, -5)
rat.numerator.should == 3
rat.denominator.should == 5
rat.should be_an_instance_of(Rational)
rat = Rational(bignum_value, 3)
rat.numerator.should == bignum_value
rat.denominator.should == 3
rat.should be_an_instance_of(Rational)
end
it "reduces the Rational" do
rat = Rational(2, 4)
rat.numerator.should == 1
rat.denominator.should == 2
rat = Rational(3, 9)
rat.numerator.should == 1
rat.denominator.should == 3
end
end
describe "when passed a String" do
it "converts the String to a Rational using the same method as String#to_r" do
r = Rational(13, 25)
s_r = ".52".to_r
r_s = Rational(".52")
r_s.should == r
r_s.should == s_r
end
it "scales the Rational value of the first argument by the Rational value of the second" do
Rational(".52", ".6").should == Rational(13, 15)
Rational(".52", "1.6").should == Rational(13, 40)
end
it "does not use the same method as Float#to_r" do
r = Rational(3, 5)
f_r = 0.6.to_r
r_s = Rational("0.6")
r_s.should == r
r_s.should_not == f_r
end
end
describe "when passed a Numeric" do
it "calls #to_r to convert the first argument to a Rational" do
num = RationalSpecs::SubNumeric.new(2)
Rational(num).should == Rational(2)
end
end
describe "when passed a Complex" do
it "returns a Rational from the real part if the imaginary part is 0" do
Rational(Complex(1, 0)).should == Rational(1)
end
it "raises a RangeError if the imaginary part is not 0" do
-> { Rational(Complex(1, 2)) }.should raise_error(RangeError)
end
end
it "raises a ZeroDivisionError if the second argument is 0" do
-> { Rational(1, 0) }.should raise_error(ZeroDivisionError, "divided by 0")
-> { Rational(1, 0.0) }.should raise_error(ZeroDivisionError, "divided by 0")
end
it "raises a TypeError if the first argument is nil" do
-> { Rational(nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is nil" do
-> { Rational(1, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if the first argument is a Symbol" do
-> { Rational(:sym) }.should raise_error(TypeError)
end
it "raises a TypeError if the second argument is a Symbol" do
-> { Rational(1, :sym) }.should raise_error(TypeError)
end
describe "when passed exception: false" do
describe "and [non-Numeric]" do
it "swallows an error" do
Rational(:sym, exception: false).should == nil
Rational("abc", exception: false).should == nil
end
end
describe "and [non-Numeric, Numeric]" do
it "swallows an error" do
Rational(:sym, 1, exception: false).should == nil
Rational("abc", 1, exception: false).should == nil
end
end
describe "and [anything, non-Numeric]" do
it "swallows an error" do
Rational(:sym, :sym, exception: false).should == nil
Rational("abc", :sym, exception: false).should == nil
end
end
describe "and non-Numeric String arguments" do
it "swallows an error" do
Rational("a", "b", exception: false).should == nil
Rational("a", 0, exception: false).should == nil
Rational(0, "b", exception: false).should == nil
end
end
describe "and nil arguments" do
it "swallows an error" do
Rational(nil, exception: false).should == nil
Rational(nil, nil, exception: false).should == nil
end
end
end
it "freezes its result" do
Rational(1).frozen?.should == true
end
end

View File

@ -1,6 +1,6 @@
require_relative '../../spec_helper'
require_relative '../../fixtures/math/common'
require_relative '../../shared/math/atanh'
require_relative 'fixtures/common'
require_relative 'shared/atanh'
describe "Math.atanh" do
it_behaves_like :math_atanh_base, :atanh, Math

View File

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
require_relative 'shared/dup'
describe "Proc#clone" do
@ -12,4 +13,18 @@ describe "Proc#clone" do
proc.clone.frozen?.should == true
end
end
ruby_version_is "3.3" do
it "calls #initialize_copy on subclass" do
obj = ProcSpecs::MyProc2.new(:a, 2) { }
dup = obj.clone
dup.should_not equal(obj)
dup.class.should == ProcSpecs::MyProc2
dup.first.should == :a
dup.second.should == 2
dup.initializer.should == :copy
end
end
end

View File

@ -1,4 +1,5 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
require_relative 'shared/dup'
describe "Proc#dup" do
@ -10,4 +11,18 @@ describe "Proc#dup" do
proc.frozen?.should == true
proc.dup.frozen?.should == false
end
ruby_version_is "3.3" do
it "calls #initialize_dup on subclass" do
obj = ProcSpecs::MyProc2.new(:a, 2) { }
dup = obj.dup
dup.should_not equal(obj)
dup.class.should == ProcSpecs::MyProc2
dup.first.should == :a
dup.second.should == 2
dup.initializer.should == :dup
end
end
end

View File

@ -32,7 +32,21 @@ module ProcSpecs
@second = b
end
attr_reader :first, :second
attr_reader :first, :second, :initializer
def initialize_copy(other)
super
@initializer = :copy
@first = other.first
@second = other.second
end
def initialize_dup(other)
super
@initializer = :dup
@first = other.first
@second = other.second
end
end
class Arity

View File

@ -1,5 +1,5 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/abs'
require_relative 'shared/abs'
describe "Rational#abs" do
it_behaves_like :rational_abs, :abs

View File

@ -1,6 +1,45 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/ceil'
describe "Rational#ceil" do
it_behaves_like :rational_ceil, :ceil
before do
@rational = Rational(2200, 7)
end
describe "with no arguments (precision = 0)" do
it "returns an Integer" do
@rational.ceil.should be_kind_of(Integer)
end
it "returns the truncated value toward positive infinity" do
@rational.ceil.should == 315
Rational(1, 2).ceil.should == 1
Rational(-1, 2).ceil.should == 0
end
end
describe "with a precision < 0" do
it "returns an Integer" do
@rational.ceil(-2).should be_kind_of(Integer)
@rational.ceil(-1).should be_kind_of(Integer)
end
it "moves the truncation point n decimal places left" do
@rational.ceil(-3).should == 1000
@rational.ceil(-2).should == 400
@rational.ceil(-1).should == 320
end
end
describe "with precision > 0" do
it "returns a Rational" do
@rational.ceil(1).should be_kind_of(Rational)
@rational.ceil(2).should be_kind_of(Rational)
end
it "moves the truncation point n decimal places right" do
@rational.ceil(1).should == Rational(3143, 10)
@rational.ceil(2).should == Rational(31429, 100)
@rational.ceil(3).should == Rational(157143, 500)
end
end
end

View File

@ -1,23 +1,93 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/comparison'
require_relative 'fixtures/rational'
describe "Rational#<=> when passed a Rational object" do
it_behaves_like :rational_cmp_rat, :<=>
it "returns 1 when self is greater than the passed argument" do
(Rational(4, 4) <=> Rational(3, 4)).should equal(1)
(Rational(-3, 4) <=> Rational(-4, 4)).should equal(1)
end
it "returns 0 when self is equal to the passed argument" do
(Rational(4, 4) <=> Rational(4, 4)).should equal(0)
(Rational(-3, 4) <=> Rational(-3, 4)).should equal(0)
end
it "returns -1 when self is less than the passed argument" do
(Rational(3, 4) <=> Rational(4, 4)).should equal(-1)
(Rational(-4, 4) <=> Rational(-3, 4)).should equal(-1)
end
end
describe "Rational#<=> when passed an Integer object" do
it_behaves_like :rational_cmp_int, :<=>
it "returns 1 when self is greater than the passed argument" do
(Rational(4, 4) <=> 0).should equal(1)
(Rational(4, 4) <=> -10).should equal(1)
(Rational(-3, 4) <=> -1).should equal(1)
end
it "returns 0 when self is equal to the passed argument" do
(Rational(4, 4) <=> 1).should equal(0)
(Rational(-8, 4) <=> -2).should equal(0)
end
it "returns -1 when self is less than the passed argument" do
(Rational(3, 4) <=> 1).should equal(-1)
(Rational(-4, 4) <=> 0).should equal(-1)
end
end
describe "Rational#<=> when passed a Float object" do
it_behaves_like :rational_cmp_float, :<=>
it "returns 1 when self is greater than the passed argument" do
(Rational(4, 4) <=> 0.5).should equal(1)
(Rational(4, 4) <=> -1.5).should equal(1)
(Rational(-3, 4) <=> -0.8).should equal(1)
end
it "returns 0 when self is equal to the passed argument" do
(Rational(4, 4) <=> 1.0).should equal(0)
(Rational(-6, 4) <=> -1.5).should equal(0)
end
it "returns -1 when self is less than the passed argument" do
(Rational(3, 4) <=> 1.2).should equal(-1)
(Rational(-4, 4) <=> 0.5).should equal(-1)
end
end
describe "Rational#<=> when passed an Object that responds to #coerce" do
it_behaves_like :rational_cmp_coerce, :<=>
it_behaves_like :rational_cmp_coerce_exception, :<=>
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational <=> obj
end
it "calls #<=> on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:<=>).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
(rational <=> obj).should == :result
end
it "does not rescue exception raised in other#coerce" do
b = mock("numeric with failed #coerce")
b.should_receive(:coerce).and_raise(RationalSpecs::CoerceError)
-> { Rational(3, 4) <=> b }.should raise_error(RationalSpecs::CoerceError)
end
end
describe "Rational#<=> when passed a non-Numeric Object that doesn't respond to #coerce" do
it_behaves_like :rational_cmp_other, :<=>
it "returns nil" do
(Rational <=> mock("Object")).should be_nil
end
end

View File

@ -1,6 +1,14 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/denominator'
describe "Rational#denominator" do
it_behaves_like :rational_denominator, :denominator
it "returns the denominator" do
Rational(3, 4).denominator.should equal(4)
Rational(3, -4).denominator.should equal(4)
Rational(1, bignum_value).denominator.should == bignum_value
end
it "returns 1 if no denominator was given" do
Rational(80).denominator.should == 1
end
end

View File

@ -1,18 +1,54 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/div'
describe "Rational#div" do
it_behaves_like :rational_div, :div
it "returns an Integer" do
Rational(229, 21).div(82).should be_kind_of(Integer)
end
it "raises an ArgumentError if passed more than one argument" do
-> { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
end
# See http://redmine.ruby-lang.org/issues/show/1648
it "raises a TypeError if passed a non-numeric argument" do
-> { Rational(3, 4).div([]) }.should raise_error(TypeError)
end
end
describe "Rational#div passed a Rational" do
it_behaves_like :rational_div_rat, :div
it "performs integer division and returns the result" do
Rational(2, 3).div(Rational(2, 3)).should == 1
Rational(-2, 9).div(Rational(-9, 2)).should == 0
end
it "raises a ZeroDivisionError when the argument has a numerator of 0" do
-> { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
-> { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#div passed an Integer" do
it_behaves_like :rational_div_int, :div
it "performs integer division and returns the result" do
Rational(2, 1).div(1).should == 2
Rational(25, 5).div(-50).should == -1
end
it "raises a ZeroDivisionError when the argument is 0" do
-> { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#div passed a Float" do
it_behaves_like :rational_div_float, :div
it "performs integer division and returns the result" do
Rational(2, 3).div(30.333).should == 0
Rational(2, 9).div(Rational(-8.6)).should == -1
Rational(3.12).div(0.5).should == 6
end
it "raises a ZeroDivisionError when the argument is 0.0" do
-> { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
end
end

View File

@ -1,20 +1,74 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/divide'
require_relative '../../shared/rational/arithmetic_exception_in_coerce'
require_relative 'shared/arithmetic_exception_in_coerce'
describe "Rational#/" do
it_behaves_like :rational_divide, :/
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational / obj
end
it "calls #/ on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:/).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
(rational / obj).should == :result
end
it_behaves_like :rational_arithmetic_exception_in_coerce, :/
end
describe "Rational#/ when passed an Integer" do
it_behaves_like :rational_divide_int, :/
it "returns self divided by other as a Rational" do
(Rational(3, 4) / 2).should eql(Rational(3, 8))
(Rational(2, 4) / 2).should eql(Rational(1, 4))
(Rational(6, 7) / -2).should eql(Rational(-3, 7))
end
it "raises a ZeroDivisionError when passed 0" do
-> { Rational(3, 4) / 0 }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#/ when passed a Rational" do
it_behaves_like :rational_divide_rat, :/
it "returns self divided by other as a Rational" do
(Rational(3, 4) / Rational(3, 4)).should eql(Rational(1, 1))
(Rational(2, 4) / Rational(1, 4)).should eql(Rational(2, 1))
(Rational(2, 4) / 2).should == Rational(1, 4)
(Rational(6, 7) / -2).should == Rational(-3, 7)
end
it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
-> { Rational(3, 4) / Rational(0, 1) }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#/ when passed a Float" do
it_behaves_like :rational_divide_float, :/
it "returns self divided by other as a Float" do
(Rational(3, 4) / 0.75).should eql(1.0)
(Rational(3, 4) / 0.25).should eql(3.0)
(Rational(3, 4) / 0.3).should eql(2.5)
(Rational(-3, 4) / 0.3).should eql(-2.5)
(Rational(3, -4) / 0.3).should eql(-2.5)
(Rational(3, 4) / -0.3).should eql(-2.5)
end
it "returns infinity when passed 0" do
(Rational(3, 4) / 0.0).infinite?.should eql(1)
(Rational(-3, -4) / 0.0).infinite?.should eql(1)
(Rational(-3, 4) / 0.0).infinite?.should eql(-1)
(Rational(3, -4) / 0.0).infinite?.should eql(-1)
end
end

View File

@ -1,14 +1,42 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/divmod'
describe "Rational#divmod when passed a Rational" do
it_behaves_like :rational_divmod_rat, :divmod
it "returns the quotient as Integer and the remainder as Rational" do
Rational(7, 4).divmod(Rational(1, 2)).should eql([3, Rational(1, 4)])
Rational(7, 4).divmod(Rational(-1, 2)).should eql([-4, Rational(-1, 4)])
Rational(0, 4).divmod(Rational(4, 3)).should eql([0, Rational(0, 1)])
Rational(bignum_value, 4).divmod(Rational(4, 3)).should eql([3458764513820540928, Rational(0, 1)])
end
it "raises a ZeroDivisionError when passed a Rational with a numerator of 0" do
-> { Rational(7, 4).divmod(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#divmod when passed an Integer" do
it_behaves_like :rational_divmod_int, :divmod
it "returns the quotient as Integer and the remainder as Rational" do
Rational(7, 4).divmod(2).should eql([0, Rational(7, 4)])
Rational(7, 4).divmod(-2).should eql([-1, Rational(-1, 4)])
Rational(bignum_value, 4).divmod(3).should eql([1537228672809129301, Rational(1, 1)])
end
it "raises a ZeroDivisionError when passed 0" do
-> { Rational(7, 4).divmod(0) }.should raise_error(ZeroDivisionError)
end
end
describe "Rational#divmod when passed a Float" do
it_behaves_like :rational_divmod_float, :divmod
it "returns the quotient as Integer and the remainder as Float" do
Rational(7, 4).divmod(0.5).should eql([3, 0.25])
end
it "returns the quotient as Integer and the remainder as Float" do
Rational(7, 4).divmod(-0.5).should eql([-4, -0.25])
end
it "raises a ZeroDivisionError when passed 0" do
-> { Rational(7, 4).divmod(0.0) }.should raise_error(ZeroDivisionError)
end
end

View File

@ -1,18 +1,39 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/equal_value'
describe "Rational#==" do
it_behaves_like :rational_equal_value, :==
it "returns the result of calling #== with self on the passed argument" do
obj = mock("Object")
obj.should_receive(:==).and_return(:result)
(Rational(3, 4) == obj).should_not be_false
end
end
describe "Rational#== when passed a Rational" do
it_behaves_like :rational_equal_value_rat, :==
it "returns true if self has the same numerator and denominator as the passed argument" do
(Rational(3, 4) == Rational(3, 4)).should be_true
(Rational(-3, -4) == Rational(3, 4)).should be_true
(Rational(-4, 5) == Rational(4, -5)).should be_true
(Rational(bignum_value, 3) == Rational(bignum_value, 3)).should be_true
(Rational(-bignum_value, 3) == Rational(bignum_value, -3)).should be_true
end
end
describe "Rational#== when passed a Float" do
it_behaves_like :rational_equal_value_float, :==
it "converts self to a Float and compares it with the passed argument" do
(Rational(3, 4) == 0.75).should be_true
(Rational(4, 2) == 2.0).should be_true
(Rational(-4, 2) == -2.0).should be_true
(Rational(4, -2) == -2.0).should be_true
end
end
describe "Rational#== when passed an Integer" do
it_behaves_like :rational_equal_value_int, :==
it "returns true if self has the passed argument as numerator and a denominator of 1" do
# Rational(x, y) reduces x and y automatically
(Rational(4, 2) == 2).should be_true
(Rational(-4, 2) == -2).should be_true
(Rational(4, -2) == -2).should be_true
end
end

View File

@ -1,6 +1,238 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/exponent'
describe "Rational#**" do
it_behaves_like :rational_exponent, :**
describe "when passed Rational" do
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
it "returns Rational(1) if the exponent is Rational(0)" do
(Rational(0) ** Rational(0)).should eql(Rational(1))
(Rational(1) ** Rational(0)).should eql(Rational(1))
(Rational(3, 4) ** Rational(0)).should eql(Rational(1))
(Rational(-1) ** Rational(0)).should eql(Rational(1))
(Rational(-3, 4) ** Rational(0)).should eql(Rational(1))
(Rational(bignum_value) ** Rational(0)).should eql(Rational(1))
(Rational(-bignum_value) ** Rational(0)).should eql(Rational(1))
end
it "returns self raised to the argument as a Rational if the exponent's denominator is 1" do
(Rational(3, 4) ** Rational(1, 1)).should eql(Rational(3, 4))
(Rational(3, 4) ** Rational(2, 1)).should eql(Rational(9, 16))
(Rational(3, 4) ** Rational(-1, 1)).should eql(Rational(4, 3))
(Rational(3, 4) ** Rational(-2, 1)).should eql(Rational(16, 9))
end
it "returns self raised to the argument as a Float if the exponent's denominator is not 1" do
(Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
(Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
(Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)
end
it "returns a complex number when self is negative and the passed argument is not 0" do
(Rational(-3, 4) ** Rational(-4, 3)).should be_close(Complex(-0.7337616108654732, 1.2709123906625817), TOLERANCE)
end
end
end
describe "when passed Integer" do
it "returns the Rational value of self raised to the passed argument" do
(Rational(3, 4) ** 4).should == Rational(81, 256)
(Rational(3, 4) ** -4).should == Rational(256, 81)
(Rational(-3, 4) ** -4).should == Rational(256, 81)
(Rational(3, -4) ** -4).should == Rational(256, 81)
(Rational(bignum_value, 4) ** 4).should == Rational(452312848583266388373324160190187140051835877600158453279131187530910662656, 1)
(Rational(3, bignum_value) ** -4).should == Rational(115792089237316195423570985008687907853269984665640564039457584007913129639936, 81)
(Rational(-bignum_value, 4) ** -4).should == Rational(1, 452312848583266388373324160190187140051835877600158453279131187530910662656)
(Rational(3, -bignum_value) ** -4).should == Rational(115792089237316195423570985008687907853269984665640564039457584007913129639936, 81)
end
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
it "returns Rational(1, 1) when the passed argument is 0" do
(Rational(3, 4) ** 0).should eql(Rational(1, 1))
(Rational(-3, 4) ** 0).should eql(Rational(1, 1))
(Rational(3, -4) ** 0).should eql(Rational(1, 1))
(Rational(bignum_value, 4) ** 0).should eql(Rational(1, 1))
(Rational(3, -bignum_value) ** 0).should eql(Rational(1, 1))
end
end
end
describe "when passed Bignum" do
# #5713
it "returns Rational(0) when self is Rational(0) and the exponent is positive" do
(Rational(0) ** bignum_value).should eql(Rational(0))
end
it "raises ZeroDivisionError when self is Rational(0) and the exponent is negative" do
-> { Rational(0) ** -bignum_value }.should raise_error(ZeroDivisionError)
end
it "returns Rational(1) when self is Rational(1)" do
(Rational(1) ** bignum_value).should eql(Rational(1))
(Rational(1) ** -bignum_value).should eql(Rational(1))
end
it "returns Rational(1) when self is Rational(-1) and the exponent is positive and even" do
(Rational(-1) ** bignum_value(0)).should eql(Rational(1))
(Rational(-1) ** bignum_value(2)).should eql(Rational(1))
end
it "returns Rational(-1) when self is Rational(-1) and the exponent is positive and odd" do
(Rational(-1) ** bignum_value(1)).should eql(Rational(-1))
(Rational(-1) ** bignum_value(3)).should eql(Rational(-1))
end
ruby_version_is ""..."3.4" do
it "returns positive Infinity when self is > 1" do
-> {
(Rational(2) ** bignum_value).infinite?.should == 1
}.should complain(/warning: in a\*\*b, b may be too big/)
-> {
(Rational(fixnum_max) ** bignum_value).infinite?.should == 1
}.should complain(/warning: in a\*\*b, b may be too big/)
end
it "returns 0.0 when self is > 1 and the exponent is negative" do
-> {
(Rational(2) ** -bignum_value).should eql(0.0)
}.should complain(/warning: in a\*\*b, b may be too big/)
-> {
(Rational(fixnum_max) ** -bignum_value).should eql(0.0)
}.should complain(/warning: in a\*\*b, b may be too big/)
end
end
ruby_version_is "3.4" do
it "raises an ArgumentError when self is > 1" do
-> {
(Rational(2) ** bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_max) ** bignum_value)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError when self is > 1 and the exponent is negative" do
-> {
(Rational(2) ** -bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_max) ** -bignum_value)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError when self is < -1" do
-> {
(Rational(-2) ** bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** bignum_value)
}.should raise_error(ArgumentError)
end
it "raises an ArgumentError when self is < -1 and the exponent is negative" do
-> {
(Rational(-2) ** -bignum_value)
}.should raise_error(ArgumentError)
-> {
(Rational(fixnum_min) ** -bignum_value)
}.should raise_error(ArgumentError)
end
end
# Fails on linux due to pow() bugs in glibc: http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
platform_is_not :linux do
ruby_version_is ""..."3.4" do
it "returns positive Infinity when self < -1" do
-> {
(Rational(-2) ** bignum_value).infinite?.should == 1
}.should complain(/warning: in a\*\*b, b may be too big/)
-> {
(Rational(-2) ** (bignum_value + 1)).infinite?.should == 1
}.should complain(/warning: in a\*\*b, b may be too big/)
-> {
(Rational(fixnum_min) ** bignum_value).infinite?.should == 1
}.should complain(/warning: in a\*\*b, b may be too big/)
end
it "returns 0.0 when self is < -1 and the exponent is negative" do
-> {
(Rational(-2) ** -bignum_value).should eql(0.0)
}.should complain(/warning: in a\*\*b, b may be too big/)
-> {
(Rational(fixnum_min) ** -bignum_value).should eql(0.0)
}.should complain(/warning: in a\*\*b, b may be too big/)
end
end
end
end
describe "when passed Float" do
it "returns self converted to Float and raised to the passed argument" do
(Rational(3, 1) ** 3.0).should eql(27.0)
(Rational(3, 1) ** 1.5).should be_close(5.19615242270663, TOLERANCE)
(Rational(3, 1) ** -1.5).should be_close(0.192450089729875, TOLERANCE)
end
it "returns a complex number if self is negative and the passed argument is not 0" do
(Rational(-3, 2) ** 1.5).should be_close(Complex(0.0, -1.8371173070873836), TOLERANCE)
(Rational(3, -2) ** 1.5).should be_close(Complex(0.0, -1.8371173070873836), TOLERANCE)
(Rational(3, -2) ** -1.5).should be_close(Complex(0.0, 0.5443310539518174), TOLERANCE)
end
it "returns Complex(1.0) when the passed argument is 0.0" do
(Rational(3, 4) ** 0.0).should == Complex(1.0)
(Rational(-3, 4) ** 0.0).should == Complex(1.0)
(Rational(-3, 4) ** 0.0).should == Complex(1.0)
end
end
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational ** obj
end
it "calls #** on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:**).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
(rational ** obj).should == :result
end
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Integer" do
[-1, -4, -9999].each do |exponent|
-> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational with denominator 1" do
[Rational(-1, 1), Rational(-3, 1)].each do |exponent|
-> { Rational(0, 1) ** exponent }.should raise_error(ZeroDivisionError, "divided by 0")
end
end
# #7513
it "raises ZeroDivisionError for Rational(0, 1) passed a negative Rational" do
-> { Rational(0, 1) ** Rational(-3, 2) }.should raise_error(ZeroDivisionError, "divided by 0")
end
platform_is_not :solaris do # See https://github.com/ruby/spec/issues/134
it "returns Infinity for Rational(0, 1) passed a negative Float" do
[-1.0, -3.0, -3.14].each do |exponent|
(Rational(0, 1) ** exponent).infinite?.should == 1
end
end
end
end

View File

@ -1,6 +1,5 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/fdiv'
describe "Rational#fdiv" do
it_behaves_like :rational_fdiv, :fdiv
it "needs to be reviewed for spec completeness"
end

View File

@ -1,6 +1,45 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/floor'
describe "Rational#floor" do
it_behaves_like :rational_floor, :floor
before do
@rational = Rational(2200, 7)
end
describe "with no arguments (precision = 0)" do
it "returns an integer" do
@rational.floor.should be_kind_of(Integer)
end
it "returns the truncated value toward negative infinity" do
@rational.floor.should == 314
Rational(1, 2).floor.should == 0
Rational(-1, 2).floor.should == -1
end
end
describe "with a precision < 0" do
it "returns an integer" do
@rational.floor(-2).should be_kind_of(Integer)
@rational.floor(-1).should be_kind_of(Integer)
end
it "moves the truncation point n decimal places left" do
@rational.floor(-3).should == 0
@rational.floor(-2).should == 300
@rational.floor(-1).should == 310
end
end
describe "with a precision > 0" do
it "returns a Rational" do
@rational.floor(1).should be_kind_of(Rational)
@rational.floor(2).should be_kind_of(Rational)
end
it "moves the truncation point n decimal places right" do
@rational.floor(1).should == Rational(1571, 5)
@rational.floor(2).should == Rational(7857, 25)
@rational.floor(3).should == Rational(62857, 200)
end
end
end

View File

@ -1,6 +1,9 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/hash'
describe "Rational#hash" do
it_behaves_like :rational_hash, :hash
# BUG: Rational(2, 3).hash == Rational(3, 2).hash
it "is static" do
Rational(2, 3).hash.should == Rational(2, 3).hash
Rational(2, 4).hash.should_not == Rational(2, 3).hash
end
end

View File

@ -1,6 +1,14 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/inspect'
describe "Rational#inspect" do
it_behaves_like :rational_inspect, :inspect
it "returns a string representation of self" do
Rational(3, 4).inspect.should == "(3/4)"
Rational(-5, 8).inspect.should == "(-5/8)"
Rational(-1, -2).inspect.should == "(1/2)"
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
Rational(bignum_value, 1).inspect.should == "(#{bignum_value}/1)"
end
end
end

View File

@ -1,5 +1,5 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/abs'
require_relative 'shared/abs'
describe "Rational#abs" do
it_behaves_like :rational_abs, :magnitude

View File

@ -1,5 +1,5 @@
require_relative '../../spec_helper'
require_relative '../../shared/rational/arithmetic_exception_in_coerce'
require_relative 'shared/arithmetic_exception_in_coerce'
describe "Rational#-" do
it_behaves_like :rational_arithmetic_exception_in_coerce, :-

View File

@ -1,6 +1,43 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/modulo'
describe "Rational#%" do
it_behaves_like :rational_modulo, :%
it "returns the remainder when this value is divided by other" do
(Rational(2, 3) % Rational(2, 3)).should == Rational(0, 1)
(Rational(4, 3) % Rational(2, 3)).should == Rational(0, 1)
(Rational(2, -3) % Rational(-2, 3)).should == Rational(0, 1)
(Rational(0, -1) % -1).should == Rational(0, 1)
(Rational(7, 4) % Rational(1, 2)).should == Rational(1, 4)
(Rational(7, 4) % 1).should == Rational(3, 4)
(Rational(7, 4) % Rational(1, 7)).should == Rational(1, 28)
(Rational(3, 4) % -1).should == Rational(-1, 4)
(Rational(1, -5) % -1).should == Rational(-1, 5)
end
it "returns a Float value when the argument is Float" do
(Rational(7, 4) % 1.0).should be_kind_of(Float)
(Rational(7, 4) % 1.0).should == 0.75
(Rational(7, 4) % 0.26).should be_close(0.19, 0.0001)
end
it "raises ZeroDivisionError on zero denominator" do
-> {
Rational(3, 5) % Rational(0, 1)
}.should raise_error(ZeroDivisionError)
-> {
Rational(0, 1) % Rational(0, 1)
}.should raise_error(ZeroDivisionError)
-> {
Rational(3, 5) % 0
}.should raise_error(ZeroDivisionError)
end
it "raises a ZeroDivisionError when the argument is 0.0" do
-> {
Rational(3, 5) % 0.0
}.should raise_error(ZeroDivisionError)
end
end

View File

@ -1,20 +1,65 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/multiply'
require_relative '../../shared/rational/arithmetic_exception_in_coerce'
require_relative 'shared/arithmetic_exception_in_coerce'
describe "Rational#*" do
it_behaves_like :rational_multiply, :*
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational * obj
end
it "calls #* on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:*).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
(rational * obj).should == :result
end
it_behaves_like :rational_arithmetic_exception_in_coerce, :*
end
describe "Rational#* passed a Rational" do
it_behaves_like :rational_multiply_rat, :*
it "returns self divided by other as a Rational" do
(Rational(3, 4) * Rational(3, 4)).should eql(Rational(9, 16))
(Rational(2, 4) * Rational(1, 4)).should eql(Rational(1, 8))
(Rational(3, 4) * Rational(0, 1)).should eql(Rational(0, 4))
end
end
describe "Rational#* passed a Float" do
it_behaves_like :rational_multiply_float, :*
it "returns self divided by other as a Float" do
(Rational(3, 4) * 0.75).should eql(0.5625)
(Rational(3, 4) * 0.25).should eql(0.1875)
(Rational(3, 4) * 0.3).should be_close(0.225, TOLERANCE)
(Rational(-3, 4) * 0.3).should be_close(-0.225, TOLERANCE)
(Rational(3, -4) * 0.3).should be_close(-0.225, TOLERANCE)
(Rational(3, 4) * -0.3).should be_close(-0.225, TOLERANCE)
(Rational(3, 4) * 0.0).should eql(0.0)
(Rational(-3, -4) * 0.0).should eql(0.0)
(Rational(-3, 4) * 0.0).should eql(0.0)
(Rational(3, -4) * 0.0).should eql(0.0)
end
end
describe "Rational#* passed an Integer" do
it_behaves_like :rational_multiply_int, :*
it "returns self divided by other as a Rational" do
(Rational(3, 4) * 2).should eql(Rational(3, 2))
(Rational(2, 4) * 2).should eql(Rational(1, 1))
(Rational(6, 7) * -2).should eql(Rational(-12, 7))
(Rational(3, 4) * 0).should eql(Rational(0, 4))
end
end

View File

@ -1,6 +1,10 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/numerator'
describe "Rational#numerator" do
it_behaves_like :rational_numerator, :numerator
it "returns the numerator" do
Rational(3, 4).numerator.should equal(3)
Rational(3, -4).numerator.should equal(-3)
Rational(bignum_value, 1).numerator.should == bignum_value
end
end

View File

@ -1,19 +1,50 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/plus'
require_relative '../../shared/rational/arithmetic_exception_in_coerce'
require_relative 'shared/arithmetic_exception_in_coerce'
describe "Rational#+" do
it_behaves_like :rational_plus, :+
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational + obj
end
it "calls #+ on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:+).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
(rational + obj).should == :result
end
it_behaves_like :rational_arithmetic_exception_in_coerce, :+
end
describe "Rational#+ with a Rational" do
it_behaves_like :rational_plus_rat, :+
it "returns the result of subtracting other from self as a Rational" do
(Rational(3, 4) + Rational(0, 1)).should eql(Rational(3, 4))
(Rational(3, 4) + Rational(1, 4)).should eql(Rational(1, 1))
(Rational(3, 4) + Rational(2, 1)).should eql(Rational(11, 4))
end
end
describe "Rational#+ with a Float" do
it_behaves_like :rational_plus_float, :+
it "returns the result of subtracting other from self as a Float" do
(Rational(3, 4) + 0.2).should eql(0.95)
(Rational(3, 4) + 2.5).should eql(3.25)
end
end
describe "Rational#+ with an Integer" do
it_behaves_like :rational_plus_int, :+
it "returns the result of subtracting other from self as a Rational" do
(Rational(3, 4) + 1).should eql(Rational(7, 4))
(Rational(3, 4) + 2).should eql(Rational(11, 4))
end
end

View File

@ -1,6 +1,25 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/divide'
describe "Rational#quo" do
it_behaves_like :rational_divide, :quo
it "calls #coerce on the passed argument with self" do
rational = Rational(3, 4)
obj = mock("Object")
obj.should_receive(:coerce).with(rational).and_return([1, 2])
rational.quo(obj)
end
it "calls #/ on the coerced Rational with the coerced Object" do
rational = Rational(3, 4)
coerced_rational = mock("Coerced Rational")
coerced_rational.should_receive(:/).and_return(:result)
coerced_obj = mock("Coerced Object")
obj = mock("Object")
obj.should_receive(:coerce).and_return([coerced_rational, coerced_obj])
rational.quo(obj).should == :result
end
end

View File

@ -1,6 +1,5 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/remainder'
describe "Rational#remainder" do
it_behaves_like :rational_remainder, :remainder
it "needs to be reviewed for spec completeness"
end

View File

@ -1,6 +1,106 @@
require_relative '../../spec_helper'
require_relative '../../shared/rational/round'
describe "Rational#round" do
it_behaves_like :rational_round, :round
before do
@rational = Rational(2200, 7)
end
describe "with no arguments (precision = 0)" do
it "returns an integer" do
@rational.round.should be_kind_of(Integer)
Rational(0, 1).round(0).should be_kind_of(Integer)
Rational(124, 1).round(0).should be_kind_of(Integer)
end
it "returns the truncated value toward the nearest integer" do
@rational.round.should == 314
Rational(0, 1).round(0).should == 0
Rational(2, 1).round(0).should == 2
end
it "returns the rounded value toward the nearest integer" do
Rational(1, 2).round.should == 1
Rational(-1, 2).round.should == -1
Rational(3, 2).round.should == 2
Rational(-3, 2).round.should == -2
Rational(5, 2).round.should == 3
Rational(-5, 2).round.should == -3
end
end
describe "with a precision < 0" do
it "returns an integer" do
@rational.round(-2).should be_kind_of(Integer)
@rational.round(-1).should be_kind_of(Integer)
Rational(0, 1).round(-1).should be_kind_of(Integer)
Rational(2, 1).round(-1).should be_kind_of(Integer)
end
it "moves the truncation point n decimal places left" do
@rational.round(-3).should == 0
@rational.round(-2).should == 300
@rational.round(-1).should == 310
end
end
describe "with a precision > 0" do
it "returns a Rational" do
@rational.round(1).should be_kind_of(Rational)
@rational.round(2).should be_kind_of(Rational)
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
Rational(0, 1).round(1).should be_kind_of(Rational)
Rational(2, 1).round(1).should be_kind_of(Rational)
end
end
it "moves the truncation point n decimal places right" do
@rational.round(1).should == Rational(3143, 10)
@rational.round(2).should == Rational(31429, 100)
@rational.round(3).should == Rational(157143, 500)
Rational(0, 1).round(1).should == Rational(0, 1)
Rational(2, 1).round(1).should == Rational(2, 1)
end
it "doesn't alter the value if the precision is too great" do
Rational(3, 2).round(10).should == Rational(3, 2).round(20)
end
# #6605
it "doesn't fail when rounding to an absurdly large positive precision" do
Rational(3, 2).round(2_097_171).should == Rational(3, 2)
end
end
describe "with half option" do
it "returns an Integer when precision is not passed" do
Rational(10, 4).round(half: nil).should == 3
Rational(10, 4).round(half: :up).should == 3
Rational(10, 4).round(half: :down).should == 2
Rational(10, 4).round(half: :even).should == 2
Rational(-10, 4).round(half: nil).should == -3
Rational(-10, 4).round(half: :up).should == -3
Rational(-10, 4).round(half: :down).should == -2
Rational(-10, 4).round(half: :even).should == -2
end
it "returns a Rational when the precision is greater than 0" do
Rational(25, 100).round(1, half: nil).should == Rational(3, 10)
Rational(25, 100).round(1, half: :up).should == Rational(3, 10)
Rational(25, 100).round(1, half: :down).should == Rational(1, 5)
Rational(25, 100).round(1, half: :even).should == Rational(1, 5)
Rational(35, 100).round(1, half: nil).should == Rational(2, 5)
Rational(35, 100).round(1, half: :up).should == Rational(2, 5)
Rational(35, 100).round(1, half: :down).should == Rational(3, 10)
Rational(35, 100).round(1, half: :even).should == Rational(2, 5)
Rational(-25, 100).round(1, half: nil).should == Rational(-3, 10)
Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10)
Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5)
Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5)
end
it "raise for a non-existent round mode" do
-> { Rational(10, 4).round(half: :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode: nonsense")
end
end
end

View File

@ -1,4 +1,4 @@
require_relative '../../spec_helper'
require_relative '../../../spec_helper'
describe :rational_abs, shared: true do
it "returns self's absolute value" do

View File

@ -1,4 +1,4 @@
require_relative '../../fixtures/rational'
require_relative '../fixtures/rational'
describe :rational_arithmetic_exception_in_coerce, shared: true do
it "does not rescue exception raised in other#coerce" do

View File

@ -1,6 +1,16 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/to_f'
describe "Rational#to_f" do
it_behaves_like :rational_to_f, :to_f
it "returns self converted to a Float" do
Rational(3, 4).to_f.should eql(0.75)
Rational(3, -4).to_f.should eql(-0.75)
Rational(-1, 4).to_f.should eql(-0.25)
Rational(-1, -4).to_f.should eql(0.25)
end
it "converts to a Float for large numerator and denominator" do
num = 1000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146010000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146010000000000000000000000000000000000048148248609680896326399448564623182963452541226153892315137780403285956264146009
den = 2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Rational(num, den).to_f.should == 500.0
end
end

View File

@ -1,6 +1,12 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/to_i'
describe "Rational#to_i" do
it_behaves_like :rational_to_i, :to_i
it "converts self to an Integer by truncation" do
Rational(7, 4).to_i.should eql(1)
Rational(11, 4).to_i.should eql(2)
end
it "converts self to an Integer by truncation" do
Rational(-7, 4).to_i.should eql(-1)
end
end

View File

@ -1,8 +1,13 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/to_r'
describe "Rational#to_r" do
it_behaves_like :rational_to_r, :to_r
it "returns self" do
a = Rational(3, 4)
a.to_r.should equal(a)
a = Rational(bignum_value, 4)
a.to_r.should equal(a)
end
it "raises TypeError trying to convert BasicObject" do
obj = BasicObject.new

View File

@ -1,6 +1,14 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/to_s'
describe "Rational#to_s" do
it_behaves_like :rational_to_s, :to_s
it "returns a string representation of self" do
# Guard against the Mathn library
guard -> { !defined?(Math.rsqrt) } do
Rational(1, 1).to_s.should == "1/1"
Rational(2, 1).to_s.should == "2/1"
end
Rational(1, 2).to_s.should == "1/2"
Rational(-1, 3).to_s.should == "-1/3"
Rational(1, -3).to_s.should == "-1/3"
end
end

View File

@ -1,6 +1,71 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/truncate'
describe "Rational#truncate" do
it_behaves_like :rational_truncate, :truncate
before do
@rational = Rational(2200, 7)
end
describe "with no arguments (precision = 0)" do
it "returns an integer" do
@rational.truncate.should be_kind_of(Integer)
end
it "returns the truncated value toward 0" do
@rational.truncate.should == 314
Rational(1, 2).truncate.should == 0
Rational(-1, 2).truncate.should == 0
end
end
describe "with an explicit precision = 0" do
it "returns an integer" do
@rational.truncate(0).should be_kind_of(Integer)
end
it "returns the truncated value toward 0" do
@rational.truncate(0).should == 314
Rational(1, 2).truncate(0).should == 0
Rational(-1, 2).truncate(0).should == 0
end
end
describe "with a precision < 0" do
it "returns an integer" do
@rational.truncate(-2).should be_kind_of(Integer)
@rational.truncate(-1).should be_kind_of(Integer)
end
it "moves the truncation point n decimal places left" do
@rational.truncate(-3).should == 0
@rational.truncate(-2).should == 300
@rational.truncate(-1).should == 310
end
end
describe "with a precision > 0" do
it "returns a Rational" do
@rational.truncate(1).should be_kind_of(Rational)
@rational.truncate(2).should be_kind_of(Rational)
end
it "moves the truncation point n decimal places right" do
@rational.truncate(1).should == Rational(1571, 5)
@rational.truncate(2).should == Rational(7857, 25)
@rational.truncate(3).should == Rational(62857, 200)
end
end
describe "with an invalid value for precision" do
it "raises a TypeError" do
-> { @rational.truncate(nil) }.should raise_error(TypeError, "not an integer")
-> { @rational.truncate(1.0) }.should raise_error(TypeError, "not an integer")
-> { @rational.truncate('') }.should raise_error(TypeError, "not an integer")
end
it "does not call to_int on the argument" do
object = Object.new
object.should_not_receive(:to_int)
-> { @rational.truncate(object) }.should raise_error(TypeError, "not an integer")
end
end
end

View File

@ -1,9 +1,6 @@
require 'win32ole'
module WIN32OLESpecs
WIN32OLERuntimeError ||= WIN32OLE::RuntimeError
WIN32OLE_TYPELIB ||= WIN32OLE::TypeLib
MSXML_AVAILABLE = WIN32OLE_TYPELIB.typelibs.any? { |t| t.name.start_with?('Microsoft XML') }
SYSTEM_MONITOR_CONTROL_AVAILABLE = WIN32OLE_TYPELIB.typelibs.any? { |t| t.name.start_with?('System Monitor Control') }

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#_getproperty" do
@ -14,6 +12,4 @@ platform_is :windows do
@dict._getproperty(0, ['key'], [WIN32OLE::VARIANT::VT_BSTR]).should == 'value'
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#_invoke" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE.codepage=" do
@ -13,6 +11,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE.connect" do
@ -15,6 +13,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE.const_load when passed Shell.Application OLE object" do
@ -32,6 +30,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE class" do
@ -42,6 +40,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE.create_guid" do
@ -9,6 +7,4 @@ platform_is :windows do
WIN32OLE.create_guid.should =~ /^\{[A-Z0-9]{8}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{4}\-[A-Z0-9]{12}/
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#invoke" do
@ -14,6 +12,4 @@ platform_is :windows do
@dict.invoke('Item', 'key').should == 'value'
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE.locale" do
@ -29,6 +27,4 @@ platform_is :windows do
end
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLESpecs.new_ole" do
@ -25,6 +23,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#ole_func_methods" do
@ -21,6 +19,4 @@ platform_is :windows do
@dict.ole_func_methods.map { |m| m.name }.include?('AddRef').should be_true
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#ole_get_methods" do
@ -16,6 +14,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
require_relative 'shared/ole_method'
@ -10,6 +8,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
require_relative 'shared/ole_method'
@ -10,6 +8,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#ole_methods" do
@ -21,6 +19,4 @@ platform_is :windows do
@dict.ole_methods.map { |m| m.name }.include?('AddRef').should be_true
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,8 +1,6 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#ole_obj_help" do
@ -18,6 +16,4 @@ platform_is :windows do
@dict.ole_obj_help.kind_of?(WIN32OLE_TYPE).should be_true
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
describe "WIN32OLE#ole_put_methods" do
@ -21,6 +19,4 @@ platform_is :windows do
@dict.ole_put_methods.map { |m| m.name }.include?('Key').should be_true
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
require_relative 'shared/setproperty'
@ -10,6 +8,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do
@ -33,6 +31,4 @@ platform_is :windows do
end
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::MSXML_AVAILABLE } do
@ -70,6 +68,4 @@ platform_is :windows do
end
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#dispid" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
@ -28,6 +26,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require_relative '../fixtures/classes'
guard -> { WIN32OLESpecs::SYSTEM_MONITOR_CONTROL_AVAILABLE } do
@ -22,6 +20,4 @@ platform_is :windows do
end
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#helpcontext" do
@ -26,6 +24,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#helpfile" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#helpstring" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#invkind" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#invoke_kind" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -2,8 +2,6 @@ require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#name" do
@ -11,6 +9,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD.new" do
@ -33,6 +31,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#offset_vtbl" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#params" do
@ -28,6 +26,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#return_type_detail" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#return_type" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#return_vtype" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#size_opt_params" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#size_params" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -2,8 +2,6 @@ require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#name" do
@ -11,6 +9,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_METHOD#visible?" do
@ -20,6 +18,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_PARAM#default" do
@ -31,6 +29,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_PARAM#input?" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -2,8 +2,6 @@ require_relative "../../../spec_helper"
require_relative 'shared/name'
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_PARAM#name" do
@ -11,6 +9,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_PARAM#ole_type_detail" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

View File

@ -1,7 +1,5 @@
require_relative "../../../spec_helper"
platform_is :windows do
verbose, $VERBOSE = $VERBOSE, nil
require 'win32ole'
describe "WIN32OLE_PARAM#ole_type" do
@ -21,6 +19,4 @@ platform_is :windows do
end
ensure
$VERBOSE = verbose
end

Some files were not shown because too many files have changed in this diff Show More