spec/mpc/functions_spec.rb in ruby-mpc-0.0.6 vs spec/mpc/functions_spec.rb in ruby-mpc-0.0.7

- old
+ new

@@ -1,11 +1,7 @@ -require File.dirname(__FILE__) + '/spec_helper.rb' +require File.join(File.dirname(__FILE__), "../spec_helper.rb") -require "generate_complex_number.rb" - -MPFR.set_default_prec(512) - FUNCTIONS_NUM_OF_CALCULATE = 100 def check_mpc_function(arg1, error = 10e-10, &block) ruby_res = yield(Complex(*(arg1.map{ |a| a.to_f }))) mpc_res = yield(MPC.new(*arg1)) @@ -16,15 +12,23 @@ (MPFR.new(ruby_res) - mpc_res).abs.should < error end end describe MPC, "when calculating some functions" do + before(:all) do + @prec_old = MPFR.get_default_prec + MPFR.set_default_prec(512) + end + it "should be the same result as Complex class" do args = GenerateComplex.float_arguments(FUNCTIONS_NUM_OF_CALCULATE) args.each do |a| check_mpc_function(a) { |b| b.abs } check_mpc_function(a) { |b| b.arg } check_mpc_function(a) { |b| b.conj } end end + + after(:all) do + MPFR.set_default_prec(@prec_old) + end end -