|
1 | 1 | require 'bigdecimal' |
2 | 2 |
|
3 | | -describe SymEngine::RealMPFR do |
4 | | - describe 'Convert BigDemcimal to RealMPFR' do |
5 | | - shared_examples 'simple real check' do |
6 | | - subject { SymEngine(value) } |
| 3 | +if SymEngine::HAVE_MPFR |
7 | 4 |
|
8 | | - it { is_expected.to be_a SymEngine::RealMPFR } |
9 | | - its(:to_f) { is_expected.to eq value.to_f } |
10 | | - end |
| 5 | + describe SymEngine::RealMPFR do |
| 6 | + describe 'Convert BigDemcimal to RealMPFR' do |
| 7 | + shared_examples 'simple real check' do |
| 8 | + subject { SymEngine(value) } |
11 | 9 |
|
12 | | - context 'positive BigDecimal' do |
13 | | - let(:value) { BigDecimal("12.3") } |
| 10 | + it { is_expected.to be_a SymEngine::RealMPFR } |
| 11 | + its(:to_f) { is_expected.to eq value.to_f } |
| 12 | + end |
14 | 13 |
|
15 | | - it_behaves_like 'simple real check' |
16 | | - end |
| 14 | + context 'positive BigDecimal' do |
| 15 | + let(:value) { BigDecimal("12.3") } |
17 | 16 |
|
18 | | - context 'negative BigDecimal' do |
19 | | - let(:value) { BigDecimal("-12.3") } |
| 17 | + it_behaves_like 'simple real check' |
| 18 | + end |
20 | 19 |
|
21 | | - it_behaves_like 'simple real check' |
| 20 | + context 'negative BigDecimal' do |
| 21 | + let(:value) { BigDecimal("-12.3") } |
| 22 | + |
| 23 | + it_behaves_like 'simple real check' |
| 24 | + end |
22 | 25 | end |
23 | | - end |
24 | 26 |
|
25 | | - describe 'Initialize RealMPFR' do |
26 | | - shared_examples 'simple real check' do |
27 | | - subject { SymEngine::RealMPFR.new(value, 200) } |
| 27 | + describe 'Initialize RealMPFR' do |
| 28 | + shared_examples 'simple real check' do |
| 29 | + subject { SymEngine::RealMPFR.new(value, 200) } |
28 | 30 |
|
29 | | - it { is_expected.to be_a SymEngine::RealMPFR } |
30 | | - its(:to_f) { is_expected.to eq value.to_f } |
31 | | - end |
| 31 | + it { is_expected.to be_a SymEngine::RealMPFR } |
| 32 | + its(:to_f) { is_expected.to eq value.to_f } |
| 33 | + end |
32 | 34 |
|
33 | | - context 'positive BigDecimal' do |
34 | | - let(:value) { BigDecimal("12.3") } |
| 35 | + context 'positive BigDecimal' do |
| 36 | + let(:value) { BigDecimal("12.3") } |
35 | 37 |
|
36 | | - it_behaves_like 'simple real check' |
37 | | - end |
| 38 | + it_behaves_like 'simple real check' |
| 39 | + end |
38 | 40 |
|
39 | | - context 'negative BigDecimal' do |
40 | | - let(:value) { BigDecimal("-12.3") } |
| 41 | + context 'negative BigDecimal' do |
| 42 | + let(:value) { BigDecimal("-12.3") } |
41 | 43 |
|
42 | | - it_behaves_like 'simple real check' |
43 | | - end |
| 44 | + it_behaves_like 'simple real check' |
| 45 | + end |
44 | 46 |
|
45 | | - context 'positive Float' do |
46 | | - let(:value) { 12.3 } |
| 47 | + context 'positive Float' do |
| 48 | + let(:value) { 12.3 } |
47 | 49 |
|
48 | | - it_behaves_like 'simple real check' |
49 | | - end |
| 50 | + it_behaves_like 'simple real check' |
| 51 | + end |
50 | 52 |
|
51 | | - context 'negative Float' do |
52 | | - let(:value) { 12.3 } |
| 53 | + context 'negative Float' do |
| 54 | + let(:value) { 12.3 } |
53 | 55 |
|
54 | | - it_behaves_like 'simple real check' |
55 | | - end |
| 56 | + it_behaves_like 'simple real check' |
| 57 | + end |
56 | 58 |
|
57 | | - context 'String representation of positive value' do |
58 | | - let(:value) { "12.3" } |
| 59 | + context 'String representation of positive value' do |
| 60 | + let(:value) { "12.3" } |
59 | 61 |
|
60 | | - it_behaves_like 'simple real check' |
61 | | - end |
| 62 | + it_behaves_like 'simple real check' |
| 63 | + end |
62 | 64 |
|
63 | | - context 'String representation of negative value' do |
64 | | - let(:value) { "-12.3" } |
| 65 | + context 'String representation of negative value' do |
| 66 | + let(:value) { "-12.3" } |
65 | 67 |
|
66 | | - it_behaves_like 'simple real check' |
| 68 | + it_behaves_like 'simple real check' |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + if SymEngine::HAVE_MPC |
| 73 | + describe SymEngine::ComplexMPC do |
| 74 | + let(:i) { SymEngine::I } |
| 75 | + let(:real) { SymEngine(BigDecimal("34.5")) } |
| 76 | + let(:imag) { SymEngine(BigDecimal("65.8")) } |
| 77 | + |
| 78 | + subject { real + i * imag } |
| 79 | + it { is_expected.to be_a SymEngine::ComplexMPC } |
| 80 | + end |
67 | 81 | end |
68 | | - end |
69 | | - |
70 | 82 |
|
| 83 | + end |
71 | 84 | end |
0 commit comments