Sha256: b2d7faef9edf6a98dfeb3e03234f660df90bbe898ad0aad2520b1b621ef149fe

Contents?: true

Size: 913 Bytes

Versions: 6

Compression:

Stored size: 913 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe "when MPFI instance is converted to string by some methods." do
  
  before(:all) do
    MPFR.set_default_prec(128)
    @row = 2
    @column = 3
    @matrixes = ((0..100).map { |i| MPFI::Matrix.new(GenerateNumber.float_arguments(@column, @row)) })
  end

  it "should return array having strings." do
    @matrixes.each do |m|
      m.str_ary_for_inspect.each_with_index do |s, i|
        s.should eql "#{m[i % @row, i / @row].left.to_strf('%.Re')} #{m[i % @row, i / @row].right.to_strf('%.Re')}"
      end
    end
  end

  it "should return inspect string." do
    @matrixes.each do |m|
      ins = m.inspect
      ins.should match(/#{Regexp.escape(sprintf("%x", m.object_id))}/)
      m.each do |a|
        str = "#{a.left.to_strf('%.Re')} #{a.right.to_strf('%.Re')}"
        ins.should match(/#{Regexp.escape(str)}/)
      end
    end
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-mpfi-0.0.7 spec/mpfi_matrix/mpfi_matrix_string_spec.rb
ruby-mpfi-0.0.6 spec/mpfi_matrix/mpfi_matrix_string_spec.rb
ruby-mpfi-0.0.5 spec/mpfi_matrix/mpfi_matrix_string_spec.rb
ruby-mpfi-0.0.4 spec/mpfi_matrix/mpfi_matrix_string_spec.rb
ruby-mpfi-0.0.3 spec/mpfi_matrix/mpfi_matrix_string_spec.rb
ruby-mpfi-0.0.2 spec/mpfi_matrix/mpfi_matrix_string_spec.rb