Skip to content

Commit 7145bea

Browse files
committed
Added Tests for Add, Mul, Pow
1 parent 603f061 commit 7145bea

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

spec/arit_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,31 @@
5555
assert e == (x + y)**2
5656
assert e != x**2 + 2 * x * y + y**2
5757
expect(e).to be_a SymEngine::Basic
58+
expect(e).to be_an_instance_of SymEngine::Pow
5859
assert f == x**2 + 2 * x * y + y**2
5960
expect(f).to be_a SymEngine::Basic
61+
expect(f).to be_an_instance_of SymEngine::Add
6062
end
6163

6264
it 'test_arit6' do
6365
x = SymEngine::Symbol.new('x')
6466
y = SymEngine::Symbol.new('y')
67+
6568
e = x + y
6669
assert(e.to_s == 'x + y') || 'y + x'
70+
expect(e).to be_an_instance_of SymEngine::Add
71+
6772
e = x * y
6873
assert(e.to_s == 'x*y') || 'y*x'
74+
expect(e).to be_an_instance_of SymEngine::Mul
75+
6976
e = Integer(2) * x
7077
assert e.to_s == '2*x'
78+
expect(e).to be_an_instance_of SymEngine::Mul
79+
7180
e = 2 * x
7281
assert e.to_s == '2*x'
82+
expect(e).to be_an_instance_of SymEngine::Mul
7383
end
7484

7585
it 'test_arit7' do

spec/basic_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
z = SymEngine::Symbol.new('z')
143143
e = (x**y + z)
144144
f = e.args
145-
expect(f).to be_an Array
145+
expect(f).to be_an_instance_of Array
146146
expect(f.length).to be 2
147147
expect(f.to_set).to eql([x**y, z].to_set)
148148
end
@@ -157,7 +157,7 @@
157157
z = SymEngine::Symbol.new('z')
158158
e = (x**y / z)
159159
f = e.free_symbols
160-
expect(f).to be_a Set
160+
expect(f).to be_an_instance_of Set
161161
expect(f.length).to be 3
162162
expect(f).to eql([x, y, z].to_set)
163163
end

spec/constant_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
context 'with summation with one' do
1919
it 'returns an initialised Basic object that is equalent to 1 + pi' do
2020
f = @a + @d
21-
expect(@a).to be_a SymEngine::Constant
21+
expect(@a).to be_an_instance_of SymEngine::Constant
2222
expect(f).to be_a SymEngine::Basic
2323
expect(f.to_s).to eql('1 + pi')
2424
end
2525
end
2626

2727
context 'with plus one and minus one' do
2828
it 'returns a Constant' do
29-
expect(1 + @a - 1).to be_a SymEngine::Constant
29+
expect(1 + @a - 1).to be_an_instance_of SymEngine::Constant
3030
end
3131
end
3232

@@ -36,15 +36,15 @@
3636
context 'with powered to zero' do
3737
it 'returns an initialised Basic object that is equalent 1' do
3838
f = @c ** @e
39-
expect(@c).to be_a SymEngine::Constant
40-
expect(f).to be_a SymEngine::Integer
39+
expect(@c).to be_an_instance_of SymEngine::Constant
40+
expect(f).to be_an_instance_of SymEngine::Integer
4141
expect(f.to_s).to eql('1')
4242
end
4343
end
4444

4545
context 'with plus one and minus one' do
4646
it 'returns a Constant' do
47-
expect(1 + @c - 1).to be_a SymEngine::Constant
47+
expect(1 + @c - 1).to be_an_instance_of SymEngine::Constant
4848
end
4949
end
5050

@@ -54,15 +54,15 @@
5454
context 'with summation with x' do
5555
it 'returns an initialised Basic object that is equalent to x + E' do
5656
f = @b + @x
57-
expect(@b).to be_a SymEngine::Constant
57+
expect(@b).to be_an_instance_of SymEngine::Constant
5858
expect(f).to be_a SymEngine::Basic
5959
expect(f.to_s).to eql('x + E')
6060
end
6161
end
6262

6363
context 'with plus one and minus one' do
6464
it 'returns a Constant' do
65-
expect(1 + @b - 1).to be_a SymEngine::Constant
65+
expect(1 + @b - 1).to be_an_instance_of SymEngine::Constant
6666
end
6767
end
6868

spec/integer_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
it 'gives a new SymEngine::Integer instance' do
88
a = SymEngine::Integer.new(123)
99
b = SymEngine::Integer.new(-123)
10-
expect(a).to be_a SymEngine::Integer
11-
expect(b).to be_a SymEngine::Integer
10+
expect(a).to be_an_instance_of SymEngine::Integer
11+
expect(b).to be_an_instance_of SymEngine::Integer
1212
expect(a.to_s).to eq('123')
1313
expect(b.to_s).to eq('-123')
1414
c = SymEngine::Integer.new(12_345_678_912_345_678_912)

0 commit comments

Comments
 (0)