File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7676 end
7777
7878 describe "when passed a Complex" do
79- it "returns a Rational from the real part if the imaginary part is 0" do
80- Rational ( Complex ( 1 , 0 ) ) . should == Rational ( 1 )
79+ context "[Complex]" do
80+ it "returns a Rational from the real part if the imaginary part is 0" do
81+ Rational ( Complex ( 1 , 0 ) ) . should == Rational ( 1 )
82+ end
83+
84+ it "raises a RangeError if the imaginary part is not 0" do
85+ -> { Rational ( Complex ( 1 , 2 ) ) } . should raise_error ( RangeError , "can't convert 1+2i into Rational" )
86+ end
8187 end
8288
83- it "raises a RangeError if the imaginary part is not 0" do
84- -> { Rational ( Complex ( 1 , 2 ) ) } . should raise_error ( RangeError )
89+ context "[Numeric, Complex]" do
90+ it "uses the real part if the imaginary part is 0" do
91+ Rational ( 1 , Complex ( 2 , 0 ) ) . should == Rational ( 1 , 2 )
92+ end
93+
94+ it "divides a numerator by the Complex denominator if the imaginary part is not 0" do
95+ Rational ( 1 , Complex ( 2 , 1 ) ) . should == Complex ( 2 /5 r, -1 /5 r)
96+ end
8597 end
8698 end
8799
You can’t perform that action at this time.
0 commit comments