summaryrefslogtreecommitdiff
path: root/spec/ruby/core/numeric/real_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/numeric/real_spec.rb')
-rw-r--r--spec/ruby/core/numeric/real_spec.rb34
1 files changed, 29 insertions, 5 deletions
diff --git a/spec/ruby/core/numeric/real_spec.rb b/spec/ruby/core/numeric/real_spec.rb
index 3e34410155..09d482a691 100644
--- a/spec/ruby/core/numeric/real_spec.rb
+++ b/spec/ruby/core/numeric/real_spec.rb
@@ -1,13 +1,37 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../../../shared/complex/numeric/real', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
describe "Numeric#real" do
- it_behaves_like(:numeric_real, :real)
+ before :each do
+ @numbers = [
+ 20, # Integer
+ 398.72, # Float
+ Rational(3, 4), # Rational
+ bignum_value, # Bignum
+ infinity_value,
+ nan_value
+ ].map{ |n| [n, -n] }.flatten
+ end
+
+ it "returns self" do
+ @numbers.each do |number|
+ if number.to_f.nan?
+ number.real.nan?.should == true
+ else
+ number.real.should == number
+ end
+ end
+ end
+
+ it "raises an ArgumentError if given any arguments" do
+ @numbers.each do |number|
+ -> { number.real(number) }.should.raise(ArgumentError)
+ end
+ end
end
describe "Numeric#real?" do
it "returns true" do
- NumericSpecs::Subclass.new.real?.should == true
+ NumericSpecs::Subclass.new.should.real?
end
end