Updated RubySpec source to 55122684.
[rbx.git] / spec / frozen / 1.8 / library / complex / to_s_spec.rb
bloba46b70812e2846623f135d4fb2d640f556b6b837
1 require File.dirname(__FILE__) + '/../../spec_helper'
2 require 'complex'
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"
8   end
9 end
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"
15     
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"
27     end
28   end
29 end