|
1 | 1 | require_relative '../../spec_helper'
|
2 | 2 | require 'bigdecimal'
|
3 | 3 |
|
4 |
| -describe "BigDecimal#precs" do |
| 4 | +ruby_version_is ""..."3.0" do |
| 5 | + describe "BigDecimal#precs" do |
5 | 6 |
|
6 |
| - before :each do |
7 |
| - @infinity = BigDecimal("Infinity") |
8 |
| - @infinity_neg = BigDecimal("-Infinity") |
9 |
| - @nan = BigDecimal("NaN") |
10 |
| - @zero = BigDecimal("0") |
11 |
| - @zero_neg = BigDecimal("-0") |
| 7 | + before :each do |
| 8 | + @infinity = BigDecimal("Infinity") |
| 9 | + @infinity_neg = BigDecimal("-Infinity") |
| 10 | + @nan = BigDecimal("NaN") |
| 11 | + @zero = BigDecimal("0") |
| 12 | + @zero_neg = BigDecimal("-0") |
12 | 13 |
|
13 |
| - @arr = [BigDecimal("2E40001"), BigDecimal("3E-20001"),\ |
14 |
| - @infinity, @infinity_neg, @nan, @zero, @zero_neg] |
15 |
| - @precision = BigDecimal::BASE.to_s.length - 1 |
16 |
| - end |
| 14 | + @arr = [BigDecimal("2E40001"), BigDecimal("3E-20001"),\ |
| 15 | + @infinity, @infinity_neg, @nan, @zero, @zero_neg] |
| 16 | + @precision = BigDecimal::BASE.to_s.length - 1 |
| 17 | + end |
17 | 18 |
|
18 |
| - it "returns array of two values" do |
19 |
| - @arr.each do |x| |
20 |
| - x.precs.kind_of?(Array).should == true |
21 |
| - x.precs.size.should == 2 |
| 19 | + it "returns array of two values" do |
| 20 | + @arr.each do |x| |
| 21 | + x.precs.kind_of?(Array).should == true |
| 22 | + x.precs.size.should == 2 |
| 23 | + end |
22 | 24 | end
|
23 |
| - end |
24 | 25 |
|
25 |
| - it "returns Integers as array values" do |
26 |
| - @arr.each do |x| |
27 |
| - x.precs[0].kind_of?(Integer).should == true |
28 |
| - x.precs[1].kind_of?(Integer).should == true |
| 26 | + it "returns Integers as array values" do |
| 27 | + @arr.each do |x| |
| 28 | + x.precs[0].kind_of?(Integer).should == true |
| 29 | + x.precs[1].kind_of?(Integer).should == true |
| 30 | + end |
29 | 31 | end
|
30 |
| - end |
31 | 32 |
|
32 |
| - it "returns the current value of significant digits as the first value" do |
33 |
| - BigDecimal("3.14159").precs[0].should >= 6 |
34 |
| - BigDecimal('1').precs[0].should == BigDecimal('1' + '0' * 100).precs[0] |
35 |
| - [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value| |
36 |
| - value.precs[0].should <= @precision |
| 33 | + it "returns the current value of significant digits as the first value" do |
| 34 | + BigDecimal("3.14159").precs[0].should >= 6 |
| 35 | + BigDecimal('1').precs[0].should == BigDecimal('1' + '0' * 100).precs[0] |
| 36 | + [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value| |
| 37 | + value.precs[0].should <= @precision |
| 38 | + end |
37 | 39 | end
|
38 |
| - end |
39 | 40 |
|
40 |
| - it "returns the maximum number of significant digits as the second value" do |
41 |
| - BigDecimal("3.14159").precs[1].should >= 6 |
42 |
| - BigDecimal('1').precs[1].should >= 1 |
43 |
| - BigDecimal('1' + '0' * 100).precs[1].should >= 101 |
44 |
| - [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value| |
45 |
| - value.precs[1].should >= 1 |
| 41 | + it "returns the maximum number of significant digits as the second value" do |
| 42 | + BigDecimal("3.14159").precs[1].should >= 6 |
| 43 | + BigDecimal('1').precs[1].should >= 1 |
| 44 | + BigDecimal('1' + '0' * 100).precs[1].should >= 101 |
| 45 | + [@infinity, @infinity_neg, @nan, @zero, @zero_neg].each do |value| |
| 46 | + value.precs[1].should >= 1 |
| 47 | + end |
46 | 48 | end
|
47 | 49 | end
|
48 | 50 | end
|
0 commit comments