1 require File.dirname(__FILE__) + '/../../spec_helper'
4 describe "Complex#to_s when self's real component is 0" do
5 it "returns only the imaginary component as String" do
6 Complex(0, 5).to_s.should == "5i"
7 Complex(0, -3.2).to_s.should == "-3.2i"
11 describe "Complex#to_s" do
12 it "returns self as String" do
13 Complex(1, 5).to_s.should == "1+5i"
14 Complex(-2.5, 1.5).to_s.should == "-2.5+1.5i"
16 Complex(1, -5).to_s.should == "1-5i"
17 Complex(-2.5, -1.5).to_s.should == "-2.5-1.5i"
19 # Guard against the Mathn library
20 conflicts_with :Prime do
21 Complex(1, 0).to_s.should == "1+0i"
22 Complex(1, -0).to_s.should == "1+0i"
24 # This is a bit weird, but it's what MRI does
25 Complex(1, 0.0).to_s.should == "1+0.0i"
26 Complex(1, -0.0).to_s.should == "1+0.0i"