rubysl-bigdecimal 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/ext/rubysl/bigdecimal/bigdecimal.c +4760 -0
  9. data/ext/rubysl/bigdecimal/bigdecimal.h +220 -0
  10. data/ext/rubysl/bigdecimal/extconf.rb +6 -0
  11. data/lib/bigdecimal.rb +1 -0
  12. data/lib/bigdecimal/README +60 -0
  13. data/lib/bigdecimal/bigdecimal_en.html +796 -0
  14. data/lib/bigdecimal/bigdecimal_ja.html +799 -0
  15. data/lib/bigdecimal/jacobian.rb +85 -0
  16. data/lib/bigdecimal/ludcmp.rb +84 -0
  17. data/lib/bigdecimal/math.rb +235 -0
  18. data/lib/bigdecimal/newton.rb +77 -0
  19. data/lib/bigdecimal/sample/linear.rb +71 -0
  20. data/lib/bigdecimal/sample/nlsolve.rb +38 -0
  21. data/lib/bigdecimal/sample/pi.rb +20 -0
  22. data/lib/bigdecimal/util.rb +65 -0
  23. data/lib/rubysl/bigdecimal.rb +2 -0
  24. data/lib/rubysl/bigdecimal/version.rb +5 -0
  25. data/rubysl-bigdecimal.gemspec +24 -0
  26. data/spec/abs_spec.rb +49 -0
  27. data/spec/add_spec.rb +178 -0
  28. data/spec/case_compare_spec.rb +6 -0
  29. data/spec/ceil_spec.rb +122 -0
  30. data/spec/coerce_spec.rb +25 -0
  31. data/spec/comparison_spec.rb +80 -0
  32. data/spec/div_spec.rb +143 -0
  33. data/spec/divide_spec.rb +6 -0
  34. data/spec/divmod_spec.rb +233 -0
  35. data/spec/double_fig_spec.rb +8 -0
  36. data/spec/eql_spec.rb +5 -0
  37. data/spec/equal_value_spec.rb +6 -0
  38. data/spec/exponent_spec.rb +37 -0
  39. data/spec/finite_spec.rb +34 -0
  40. data/spec/fix_spec.rb +56 -0
  41. data/spec/fixtures/classes.rb +17 -0
  42. data/spec/floor_spec.rb +109 -0
  43. data/spec/frac_spec.rb +47 -0
  44. data/spec/gt_spec.rb +86 -0
  45. data/spec/gte_spec.rb +90 -0
  46. data/spec/induced_from_spec.rb +36 -0
  47. data/spec/infinite_spec.rb +31 -0
  48. data/spec/inspect_spec.rb +40 -0
  49. data/spec/limit_spec.rb +29 -0
  50. data/spec/lt_spec.rb +84 -0
  51. data/spec/lte_spec.rb +90 -0
  52. data/spec/minus_spec.rb +57 -0
  53. data/spec/mode_spec.rb +64 -0
  54. data/spec/modulo_spec.rb +11 -0
  55. data/spec/mult_spec.rb +23 -0
  56. data/spec/multiply_spec.rb +25 -0
  57. data/spec/nan_spec.rb +22 -0
  58. data/spec/new_spec.rb +120 -0
  59. data/spec/nonzero_spec.rb +28 -0
  60. data/spec/plus_spec.rb +49 -0
  61. data/spec/power_spec.rb +5 -0
  62. data/spec/precs_spec.rb +48 -0
  63. data/spec/quo_spec.rb +12 -0
  64. data/spec/remainder_spec.rb +83 -0
  65. data/spec/round_spec.rb +193 -0
  66. data/spec/shared/eql.rb +65 -0
  67. data/spec/shared/modulo.rb +146 -0
  68. data/spec/shared/mult.rb +97 -0
  69. data/spec/shared/power.rb +83 -0
  70. data/spec/shared/quo.rb +59 -0
  71. data/spec/shared/to_int.rb +27 -0
  72. data/spec/sign_spec.rb +46 -0
  73. data/spec/split_spec.rb +87 -0
  74. data/spec/sqrt_spec.rb +111 -0
  75. data/spec/sub_spec.rb +52 -0
  76. data/spec/to_f_spec.rb +54 -0
  77. data/spec/to_i_spec.rb +6 -0
  78. data/spec/to_int_spec.rb +7 -0
  79. data/spec/to_s_spec.rb +71 -0
  80. data/spec/truncate_spec.rb +100 -0
  81. data/spec/uminus_spec.rb +57 -0
  82. data/spec/uplus_spec.rb +19 -0
  83. data/spec/ver_spec.rb +10 -0
  84. data/spec/zero_spec.rb +27 -0
  85. metadata +243 -0
@@ -0,0 +1,8 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal.double_fig" do
4
+ # The result depends on the CPU and OS
5
+ it "returns the number of digits a Float number is allowed to have" do
6
+ BigDecimal.double_fig.should_not == nil
7
+ end
8
+ end
data/spec/eql_spec.rb ADDED
@@ -0,0 +1,5 @@
1
+ require File.expand_path('../shared/eql.rb', __FILE__)
2
+
3
+ describe "BigDecimal#eql?" do
4
+ it_behaves_like(:bigdecimal_eql, :eql?)
5
+ end
@@ -0,0 +1,6 @@
1
+ require File.expand_path('../shared/eql.rb', __FILE__)
2
+
3
+
4
+ describe "BigDecimal#==" do
5
+ it_behaves_like(:bigdecimal_eql, :==)
6
+ end
@@ -0,0 +1,37 @@
1
+ require File.expand_path('../shared/power', __FILE__)
2
+ require 'bigdecimal'
3
+
4
+ describe "BigDecimal#**" do
5
+ it_behaves_like(:bigdecimal_power, :**)
6
+ end
7
+
8
+ describe "BigDecimal#exponent" do
9
+
10
+ it "returns an Integer" do
11
+ BigDecimal("2E100000000").exponent.kind_of?(Integer).should == true
12
+ BigDecimal("2E-999").exponent.kind_of?(Integer).should == true
13
+ end
14
+
15
+ it "is n if number can be represented as 0.xxx*10**n" do
16
+ BigDecimal("2E1000").exponent.should == 1001
17
+ BigDecimal("1234567E10").exponent.should == 17
18
+ end
19
+
20
+ # commenting this spec out after discussion with Defiler, since it seems to be an MRI bug, not a real feature
21
+ =begin
22
+ platform_is :wordsize => 32 do
23
+ # TODO: write specs for both 32 and 64 bit
24
+ it "returns 0 if exponent can't be represented as Fixnum" do
25
+ BigDecimal("2E1000000000000000").exponent.should == 0
26
+ BigDecimal("-5E-999999999999999").exponent.should == 0
27
+ end
28
+ end
29
+ =end
30
+
31
+ it "returns 0 if self is 0" do
32
+ BigDecimal("0").exponent.should == 0
33
+ BigDecimal("+0").exponent.should == 0
34
+ BigDecimal("-0").exponent.should == 0
35
+ end
36
+
37
+ end
@@ -0,0 +1,34 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#finite?" do
4
+ before(:each) do
5
+ @one = BigDecimal("1")
6
+ @zero = BigDecimal("0")
7
+ @zero_pos = BigDecimal("+0")
8
+ @zero_neg = BigDecimal("-0")
9
+ @two = BigDecimal("2")
10
+ @three = BigDecimal("3")
11
+ @nan = BigDecimal("NaN")
12
+ @infinity = BigDecimal("Infinity")
13
+ @infinity_minus = BigDecimal("-Infinity")
14
+ @one_minus = BigDecimal("-1")
15
+ @frac_1 = BigDecimal("1E-99999")
16
+ @frac_2 = BigDecimal("0.9E-99999")
17
+ @big = BigDecimal("2E40001")
18
+ @finite_vals = [@one, @zero, @zero_pos, @zero_neg, @two,
19
+ @three, @frac_1, @frac_2, @big, @one_minus]
20
+ end
21
+
22
+ it "is false if Infinity or NaN" do
23
+ @infinity.finite?.should == false
24
+ @infinity_minus.finite?.should == false
25
+ @nan.finite?.should == false
26
+ end
27
+
28
+ it "returns true for finite values" do
29
+ @finite_vals.each do |val|
30
+ val.finite?.should == true
31
+ end
32
+ end
33
+ end
34
+
data/spec/fix_spec.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#fix" do
4
+ before(:each) do
5
+ @zero = BigDecimal("0")
6
+ @mixed = BigDecimal("1.23456789")
7
+ @pos_int = BigDecimal("2E5555")
8
+ @neg_int = BigDecimal("-2E5555")
9
+ @pos_frac = BigDecimal("2E-9999")
10
+ @neg_frac = BigDecimal("-2E-9999")
11
+
12
+ @infinity = BigDecimal("Infinity")
13
+ @infinity_neg = BigDecimal("-Infinity")
14
+ @nan = BigDecimal("NaN")
15
+ @zero_pos = BigDecimal("+0")
16
+ @zero_neg = BigDecimal("-0")
17
+ end
18
+
19
+ it "returns a BigDecimal" do
20
+ BigDecimal("2E100000000").fix.kind_of?(BigDecimal).should == true
21
+ BigDecimal("2E-999").kind_of?(BigDecimal).should == true
22
+ end
23
+
24
+ it "returns the integer part of the absolute value" do
25
+ a = BigDecimal("2E1000")
26
+ a.fix.should == a
27
+ b = BigDecimal("-2E1000")
28
+ b.fix.should == b
29
+ BigDecimal("0.123456789E5").fix.should == BigDecimal("0.12345E5")
30
+ BigDecimal("-0.123456789E5").fix.should == BigDecimal("-0.12345E5")
31
+ end
32
+
33
+ it "correctly handles special values" do
34
+ @infinity.fix.should == @infinity
35
+ @infinity_neg.fix.should == @infinity_neg
36
+ @nan.fix.nan?.should == true
37
+ end
38
+
39
+ it "returns 0 if the absolute value is < 1" do
40
+ BigDecimal("0.99999").fix.should == 0
41
+ BigDecimal("-0.99999").fix.should == 0
42
+ BigDecimal("0.000000001").fix.should == 0
43
+ BigDecimal("-0.00000001").fix.should == 0
44
+ BigDecimal("-1000000").fix.should_not == 0
45
+ @zero.fix.should == 0
46
+ @zero_pos.fix.should == @zero_pos
47
+ @zero_neg.fix.should == @zero_neg
48
+ end
49
+
50
+ it "does not allow any arguments" do
51
+ lambda {
52
+ @mixed.fix(10)
53
+ }.should raise_error(ArgumentError)
54
+ end
55
+
56
+ end
@@ -0,0 +1,17 @@
1
+ module BigDecimalSpecs
2
+ # helper method to sure that the global limit is reset back
3
+ def self.with_limit(l)
4
+ old = BigDecimal.limit(l)
5
+ yield
6
+ ensure
7
+ BigDecimal.limit(old)
8
+ end
9
+
10
+ def self.with_rounding(r)
11
+ old = BigDecimal.mode(BigDecimal::ROUND_MODE)
12
+ BigDecimal.mode(BigDecimal::ROUND_MODE, r)
13
+ yield
14
+ ensure
15
+ BigDecimal.mode(BigDecimal::ROUND_MODE, old)
16
+ end
17
+ end
@@ -0,0 +1,109 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#floor" do
4
+ before(:each) do
5
+ @one = BigDecimal("1")
6
+ @three = BigDecimal("3")
7
+ @four = BigDecimal("4")
8
+ @zero = BigDecimal("0")
9
+ @mixed = BigDecimal("1.23456789")
10
+ @mixed_big = BigDecimal("1.23456789E100")
11
+ @pos_int = BigDecimal("2E5555")
12
+ @neg_int = BigDecimal("-2E5555")
13
+ @pos_frac = BigDecimal("2E-9999")
14
+ @neg_frac = BigDecimal("-2E-9999")
15
+
16
+ @infinity = BigDecimal("Infinity")
17
+ @infinity_neg = BigDecimal("-Infinity")
18
+ @nan = BigDecimal("NaN")
19
+ @zero_pos = BigDecimal("+0")
20
+ @zero_neg = BigDecimal("-0")
21
+ end
22
+
23
+ it "returns the greatest integer smaller or equal to self" do
24
+ @pos_int.floor.should == @pos_int
25
+ @neg_int.floor.should == @neg_int
26
+ @pos_frac.floor.should == @zero
27
+ @neg_frac.floor.should == BigDecimal("-1")
28
+ @zero.floor.should == 0
29
+ @zero_pos.floor.should == @zero_pos
30
+ @zero_neg.floor.should == @zero_neg
31
+
32
+ BigDecimal('2.3').floor.should == 2
33
+ BigDecimal('2.5').floor.should == 2
34
+ BigDecimal('2.9999').floor.should == 2
35
+ BigDecimal('-2.3').floor.should == -3
36
+ BigDecimal('-2.5').floor.should == -3
37
+ BigDecimal('-2.9999').floor.should == -3
38
+ BigDecimal('0.8').floor.should == 0
39
+ BigDecimal('-0.8').floor.should == -1
40
+ end
41
+
42
+ ruby_version_is "" ... "1.9" do
43
+ it "returns the same value, if self is special value" do
44
+ @infinity.floor.should == @infinity
45
+ @infinity_neg.floor.should == @infinity_neg
46
+ @nan.floor.nan?.should == true
47
+ end
48
+ end
49
+
50
+ ruby_version_is "1.9" do
51
+ it "raise exception, if self is special value" do
52
+ lambda { @infinity.floor }.should raise_error(FloatDomainError)
53
+ lambda { @infinity_neg.floor }.should raise_error(FloatDomainError)
54
+ lambda { @nan.floor }.should raise_error(FloatDomainError)
55
+ end
56
+ end
57
+
58
+ it "returns n digits right of the decimal point if given n > 0" do
59
+ @mixed.floor(1).should == BigDecimal("1.2")
60
+ @mixed.floor(5).should == BigDecimal("1.23456")
61
+
62
+ BigDecimal("-0.03").floor(1).should == BigDecimal("-0.1")
63
+ BigDecimal("0.03").floor(1).should == BigDecimal("0")
64
+
65
+ BigDecimal("23.45").floor(0).should == BigDecimal('23')
66
+ BigDecimal("23.45").floor(1).should == BigDecimal('23.4')
67
+ BigDecimal("23.45").floor(2).should == BigDecimal('23.45')
68
+
69
+ BigDecimal("-23.45").floor(0).should == BigDecimal('-24')
70
+ BigDecimal("-23.45").floor(1).should == BigDecimal('-23.5')
71
+ BigDecimal("-23.45").floor(2).should == BigDecimal('-23.45')
72
+
73
+ BigDecimal("2E-10").floor(0).should == @zero
74
+ BigDecimal("2E-10").floor(9).should == @zero
75
+ BigDecimal("2E-10").floor(10).should == BigDecimal('2E-10')
76
+ BigDecimal("2E-10").floor(11).should == BigDecimal('2E-10')
77
+
78
+ (1..10).each do |n|
79
+ # 0.3, 0.33, 0.333, etc.
80
+ (@one.div(@three,20)).floor(n).should == BigDecimal("0.#{'3'*n}")
81
+ # 1.3, 1.33, 1.333, etc.
82
+ (@four.div(@three,20)).floor(n).should == BigDecimal("1.#{'3'*n}")
83
+ (BigDecimal('31').div(@three,20)).floor(n).should == BigDecimal("10.#{'3'*n}")
84
+ end
85
+ (1..10).each do |n|
86
+ # -0.4, -0.34, -0.334, etc.
87
+ (-@one.div(@three,20)).floor(n).should == BigDecimal("-0.#{'3'*(n-1)}4")
88
+ end
89
+ (1..10).each do |n|
90
+ (@three.div(@one,20)).floor(n).should == @three
91
+ end
92
+ (1..10).each do |n|
93
+ (-@three.div(@one,20)).floor(n).should == -@three
94
+ end
95
+ end
96
+
97
+ it "sets n digits left of the decimal point to 0, if given n < 0" do
98
+ BigDecimal("13345.234").floor(-2).should == BigDecimal("13300.0")
99
+ @mixed_big.floor(-99).should == BigDecimal("0.12E101")
100
+ @mixed_big.floor(-100).should == BigDecimal("0.1E101")
101
+ @mixed_big.floor(-95).should == BigDecimal("0.123456E101")
102
+ (1..10).each do |n|
103
+ BigDecimal('1.8').floor(-n).should == @zero
104
+ end
105
+ BigDecimal("1E10").floor(-30).should == @zero
106
+ BigDecimal("-1E10").floor(-30).should == BigDecimal('-1E30')
107
+ end
108
+
109
+ end
data/spec/frac_spec.rb ADDED
@@ -0,0 +1,47 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#frac" do
4
+ before(:each) do
5
+ @zero = BigDecimal("0")
6
+ @mixed = BigDecimal("1.23456789")
7
+ @pos_int = BigDecimal("2E5555")
8
+ @neg_int = BigDecimal("-2E5555")
9
+ @pos_frac = BigDecimal("2E-9999")
10
+ @neg_frac = BigDecimal("-2E-9999")
11
+
12
+ @infinity = BigDecimal("Infinity")
13
+ @infinity_neg = BigDecimal("-Infinity")
14
+ @nan = BigDecimal("NaN")
15
+ @zero_pos = BigDecimal("+0")
16
+ @zero_neg = BigDecimal("-0")
17
+ end
18
+
19
+ it "returns a BigDecimal" do
20
+ @pos_int.frac.kind_of?(BigDecimal).should == true
21
+ @neg_int.frac.kind_of?(BigDecimal).should == true
22
+ @pos_frac.kind_of?(BigDecimal).should == true
23
+ @neg_frac.kind_of?(BigDecimal).should == true
24
+ end
25
+
26
+ it "returns the fractional part of the absolute value" do
27
+ @mixed.frac.should == BigDecimal("0.23456789")
28
+ @pos_frac.frac.should == @pos_frac
29
+ @neg_frac.frac.should == @neg_frac
30
+ end
31
+
32
+ it "returns 0 if the value is 0" do
33
+ @zero.frac.should == @zero
34
+ end
35
+
36
+ it "returns 0 if the value is an integer" do
37
+ @pos_int.frac.should == @zero
38
+ @neg_int.frac.should == @zero
39
+ end
40
+
41
+ it "correctly handles special values" do
42
+ @infinity.frac.should == @infinity
43
+ @infinity_neg.frac.should == @infinity_neg
44
+ @nan.frac.nan?.should == true
45
+ end
46
+
47
+ end
data/spec/gt_spec.rb ADDED
@@ -0,0 +1,86 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#>" do
4
+ before(:each) do
5
+ @zero = BigDecimal("0")
6
+ @zero_pos = BigDecimal("+0")
7
+ @zero_neg = BigDecimal("-0")
8
+ @mixed = BigDecimal("1.23456789")
9
+ @pos_int = BigDecimal("2E5555")
10
+ @neg_int = BigDecimal("-2E5555")
11
+ @pos_frac = BigDecimal("2E-9999")
12
+ @neg_frac = BigDecimal("-2E-9999")
13
+
14
+ @int_mock = mock('123')
15
+ class << @int_mock
16
+ def coerce(other)
17
+ return [other, BigDecimal('123')]
18
+ end
19
+ def > (other)
20
+ BigDecimal('123') > other
21
+ end
22
+ end
23
+
24
+ @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
25
+ -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
26
+ @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
27
+
28
+ @infinity = BigDecimal("Infinity")
29
+ @infinity_neg = BigDecimal("-Infinity")
30
+ @nan = BigDecimal("NaN")
31
+ end
32
+
33
+ it "returns true if a > b" do
34
+ one = BigDecimal("1")
35
+ two = BigDecimal("2")
36
+
37
+ frac_1 = BigDecimal("1E-99999")
38
+ frac_2 = BigDecimal("0.9E-99999")
39
+ (@zero > one).should == false
40
+ (two > @zero).should == true
41
+ (frac_2 > frac_1).should == false
42
+
43
+ (@neg_int > @pos_int).should == false
44
+ (@pos_int > @neg_int).should == true
45
+ (@neg_int > @pos_frac).should == false
46
+ (@pos_frac > @neg_int).should == true
47
+ (@zero > @zero_pos).should == false
48
+ (@zero > @zero_neg).should == false
49
+ (@zero_neg > @zero_pos).should == false
50
+ (@zero_pos > @zero_neg).should == false
51
+ end
52
+
53
+ it "properly handles infinity values" do
54
+ @values.each { |val|
55
+ (val > @infinity).should == false
56
+ (@infinity > val).should == true
57
+ (val > @infinity_neg).should == true
58
+ (@infinity_neg > val).should == false
59
+ }
60
+ (@infinity > @infinity).should == false
61
+ (@infinity_neg > @infinity_neg).should == false
62
+ (@infinity > @infinity_neg).should == true
63
+ (@infinity_neg > @infinity).should == false
64
+ end
65
+
66
+ ruby_bug "redmine:2349", "1.8.7" do
67
+ it "properly handles NaN values" do
68
+ @values += [@infinity, @infinity_neg, @nan]
69
+ @values.each { |val|
70
+ (@nan > val).should == false
71
+ (val > @nan).should == false
72
+ }
73
+ end
74
+ end
75
+
76
+ ruby_bug "redmine:2349", "1.8.7" do
77
+ it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
78
+ lambda {@zero > nil }.should raise_error(ArgumentError)
79
+ lambda {@infinity > nil }.should raise_error(ArgumentError)
80
+ lambda {@infinity_neg > nil }.should raise_error(ArgumentError)
81
+ lambda {@mixed > nil }.should raise_error(ArgumentError)
82
+ lambda {@pos_int > nil }.should raise_error(ArgumentError)
83
+ lambda {@neg_frac > nil }.should raise_error(ArgumentError)
84
+ end
85
+ end
86
+ end
data/spec/gte_spec.rb ADDED
@@ -0,0 +1,90 @@
1
+ require 'bigdecimal'
2
+
3
+ describe "BigDecimal#>=" do
4
+ before(:each) do
5
+ @zero = BigDecimal("0")
6
+ @zero_pos = BigDecimal("+0")
7
+ @zero_neg = BigDecimal("-0")
8
+ @mixed = BigDecimal("1.23456789")
9
+ @pos_int = BigDecimal("2E5555")
10
+ @neg_int = BigDecimal("-2E5555")
11
+ @pos_frac = BigDecimal("2E-9999")
12
+ @neg_frac = BigDecimal("-2E-9999")
13
+
14
+ @int_mock = mock('123')
15
+ class << @int_mock
16
+ def coerce(other)
17
+ return [other, BigDecimal('123')]
18
+ end
19
+ def >= (other)
20
+ BigDecimal('123') >= other
21
+ end
22
+ end
23
+
24
+ @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
25
+ -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
26
+ @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
27
+
28
+ @infinity = BigDecimal("Infinity")
29
+ @infinity_neg = BigDecimal("-Infinity")
30
+ @nan = BigDecimal("NaN")
31
+ end
32
+
33
+ it "returns true if a >= b" do
34
+ one = BigDecimal("1")
35
+ two = BigDecimal("2")
36
+
37
+ frac_1 = BigDecimal("1E-99999")
38
+ frac_2 = BigDecimal("0.9E-99999")
39
+
40
+ (@zero >= one).should == false
41
+ (two >= @zero).should == true
42
+
43
+ (frac_2 >= frac_1).should == false
44
+ (two >= two).should == true
45
+ (frac_1 >= frac_1).should == true
46
+
47
+ (@neg_int >= @pos_int).should == false
48
+ (@pos_int >= @neg_int).should == true
49
+ (@neg_int >= @pos_frac).should == false
50
+ (@pos_frac >= @neg_int).should == true
51
+ (@zero >= @zero_pos).should == true
52
+ (@zero >= @zero_neg).should == true
53
+ (@zero_neg >= @zero_pos).should == true
54
+ (@zero_pos >= @zero_neg).should == true
55
+ end
56
+
57
+ it "properly handles infinity values" do
58
+ @values.each { |val|
59
+ (val >= @infinity).should == false
60
+ (@infinity >= val).should == true
61
+ (val >= @infinity_neg).should == true
62
+ (@infinity_neg >= val).should == false
63
+ }
64
+ (@infinity >= @infinity).should == true
65
+ (@infinity_neg >= @infinity_neg).should == true
66
+ (@infinity >= @infinity_neg).should == true
67
+ (@infinity_neg >= @infinity).should == false
68
+ end
69
+
70
+ ruby_bug "redmine:2349", "1.8.7" do
71
+ it "properly handles NaN values" do
72
+ @values += [@infinity, @infinity_neg, @nan]
73
+ @values.each { |val|
74
+ (@nan >= val).should == false
75
+ (val >= @nan).should == false
76
+ }
77
+ end
78
+ end
79
+
80
+ ruby_bug "redmine:2349", "1.8.7" do
81
+ it "returns nil if the argument is nil" do
82
+ lambda {@zero >= nil }.should raise_error(ArgumentError)
83
+ lambda {@infinity >= nil }.should raise_error(ArgumentError)
84
+ lambda {@infinity_neg >= nil }.should raise_error(ArgumentError)
85
+ lambda {@mixed >= nil }.should raise_error(ArgumentError)
86
+ lambda {@pos_int >= nil }.should raise_error(ArgumentError)
87
+ lambda {@neg_frac >= nil }.should raise_error(ArgumentError)
88
+ end
89
+ end
90
+ end