|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe SymEngine do |
| 4 | + before :each do |
| 5 | + end |
| 6 | + |
| 7 | + describe 'Constant' do |
| 8 | + before :each do |
| 9 | + @a = SymEngine::PI |
| 10 | + @b = SymEngine::E |
| 11 | + @c = SymEngine::EULER_GAMMA |
| 12 | + @d = SymEngine::Integer.new(1); |
| 13 | + @e = SymEngine::Integer.new(0); |
| 14 | + @x = SymEngine::Symbol.new("x"); |
| 15 | + end |
| 16 | + |
| 17 | + describe '#pi' do |
| 18 | + context 'with summation with one' do |
| 19 | + it 'returns an initialised Basic object that is equalent to 1 + pi' do |
| 20 | + f = @a + @d |
| 21 | + expect(@a).to be_an_instance_of SymEngine::Constant |
| 22 | + expect(f).to be_an_instance_of SymEngine::Basic |
| 23 | + expect(f.to_s).to eql('1 + pi') |
| 24 | + end |
| 25 | + end |
| 26 | + |
| 27 | + context 'with plus one and minus one' do |
| 28 | + it 'returns a Constant' do |
| 29 | + expect(1 + @a - 1).to be_an_instance_of SymEngine::Constant |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + end |
| 34 | + |
| 35 | + describe '#EulerGamma' do |
| 36 | + context 'with powered to zero' do |
| 37 | + it 'returns an initialised Basic object that is equalent 1' do |
| 38 | + f = @c ** @e |
| 39 | + expect(@c).to be_an_instance_of SymEngine::Constant |
| 40 | + expect(f).to be_an_instance_of SymEngine::Integer |
| 41 | + expect(f.to_s).to eql('1') |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + context 'with plus one and minus one' do |
| 46 | + it 'returns a Constant' do |
| 47 | + expect(1 + @c - 1).to be_an_instance_of SymEngine::Constant |
| 48 | + end |
| 49 | + end |
| 50 | + |
| 51 | + end |
| 52 | + |
| 53 | + describe '#E' do |
| 54 | + context 'with summation with x' do |
| 55 | + it 'returns an initialised Basic object that is equalent to x + E' do |
| 56 | + f = @b + @x |
| 57 | + expect(@b).to be_an_instance_of SymEngine::Constant |
| 58 | + expect(f).to be_an_instance_of SymEngine::Basic |
| 59 | + expect(f.to_s).to eql('x + E') |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + context 'with plus one and minus one' do |
| 64 | + it 'returns a Constant' do |
| 65 | + expect(1 + @b - 1).to be_an_instance_of SymEngine::Constant |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + end |
| 70 | + |
| 71 | + end |
| 72 | +end |
0 commit comments