Project

General

Profile

Backport #9305 ยป bigdecimal_spec.rb

kwerle (Kurt Werle), 12/27/2013 06:57 AM

 
1
# Values are taken from non-shareable code base
2

    
3
require 'bigdecimal'
4

    
5
require 'minitest/autorun'
6

    
7
describe BigDecimal do
8
  before do
9
    @args = {north_south: 700, cam_load: BigDecimal.new("0.9932")}
10
    @max_force = BigDecimal.new "0.344045"
11
  end
12

    
13
  it "should have a numerator" do
14
    assert_in_delta @args[:cam_load], 0.9932
15
  end
16

    
17
  it "should have a denominator" do
18
    assert_in_delta ((@args[:north_south] * @max_force) / BigDecimal.new('1000.0')), 0.2408315
19
  end
20

    
21
  it "should pass float math" do
22
    assert_in_delta 0.9932 / 0.2408315, 4.124045235
23
  end
24

    
25
  # This test passes on ruby 2.0 and fails on Ruby 2.1
26
  it "should pass big math" do
27
    assert_in_delta @args[:cam_load] / ((@args[:north_south] * @max_force) / BigDecimal.new('1000.0')), 4.124045235
28
  end
29
end