1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-01-29 16:08:16 +00:00
parent 1e658d45e1
commit 3fa5bd38af
494 changed files with 4133 additions and 3109 deletions

View file

@ -35,7 +35,7 @@ describe :kernel_Complex, shared: true do
end
end
describe "when passed [Integer]" do
describe "when passed [Integer/Float]" do
it "returns a new Complex number with 0 as the imaginary component" do
# Guard against the Mathn library
conflicts_with :Prime do
@ -62,7 +62,7 @@ describe :kernel_Complex, shared: true do
it "needs to be reviewed for spec completeness"
end
describe "when passed an Objectc which responds to #to_c" do
describe "when passed an Object which responds to #to_c" do
it "returns the passed argument" do
obj = Object.new; def obj.to_c; 1i end
Complex(obj).should == Complex(0, 1)
@ -130,4 +130,12 @@ describe :kernel_Complex, shared: true do
lambda { Complex.send(@method, 0, :sym) }.should raise_error(TypeError)
end
end
describe "when passed nil" do
it "raises TypeError" do
lambda { Complex(nil) }.should raise_error(TypeError, "can't convert nil into Complex")
lambda { Complex(0, nil) }.should raise_error(TypeError, "can't convert nil into Complex")
lambda { Complex(nil, 0) }.should raise_error(TypeError, "can't convert nil into Complex")
end
end
end

View file

@ -1,16 +0,0 @@
require File.expand_path('../../../spec_helper', __FILE__)
describe :complex_hash, shared: true do
it "is static" do
Complex(1).hash.should == Complex(1).hash
Complex(1, 0).hash.should == Complex(1).hash
Complex(1, 1).hash.should == Complex(1, 1).hash
end
it "is different for different instances" do
Complex(1, 2).hash.should_not == Complex(1, 1).hash
Complex(2, 1).hash.should_not == Complex(1, 1).hash
Complex(1, 2).hash.should_not == Complex(2, 1).hash
end
end