Skip to content

Commit f050b48

Browse files
committed
Function class tests
1 parent ff90caf commit f050b48

File tree

1 file changed

+197
-3
lines changed

1 file changed

+197
-3
lines changed

spec/functions_spec.rb

Lines changed: 197 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
expect(f).to eql(0)
2323
end
2424
end
25+
context 'sin(2x)' do
26+
it 'is an instance of sin' do
27+
f = SymEngine::sin(2*@x)
28+
expect(f).to be_an_instance_of SymEngine::Sin
29+
expect(f.to_s).to eql("sin(2*x)")
30+
end
31+
end
2532
end
2633

2734
describe '#cos' do
@@ -31,6 +38,13 @@
3138
expect(f).to eql(-1)
3239
end
3340
end
41+
context 'cos(2x)' do
42+
it 'is an instance of cos' do
43+
f = SymEngine::cos(2*@x)
44+
expect(f).to be_an_instance_of SymEngine::Cos
45+
expect(f.to_s).to eql("cos(2*x)")
46+
end
47+
end
3448
end
3549

3650
describe '#tan' do
@@ -40,6 +54,13 @@
4054
expect(f).to eql(0)
4155
end
4256
end
57+
context 'tan(2x)' do
58+
it 'is an instance of tan' do
59+
f = SymEngine::tan(2*@x)
60+
expect(f).to be_an_instance_of SymEngine::Tan
61+
expect(f.to_s).to eql("tan(2*x)")
62+
end
63+
end
4364
end
4465

4566
describe '#csc' do
@@ -49,6 +70,13 @@
4970
expect(f).to eql(1)
5071
end
5172
end
73+
context 'csc(2x)' do
74+
it 'is an instance of csc' do
75+
f = SymEngine::csc(2*@x)
76+
expect(f).to be_an_instance_of SymEngine::Csc
77+
expect(f.to_s).to eql("csc(2*x)")
78+
end
79+
end
5280
end
5381

5482
describe '#sec' do
@@ -58,6 +86,13 @@
5886
expect(f).to eql(-1)
5987
end
6088
end
89+
context 'sec(2x)' do
90+
it 'is an instance of sec' do
91+
f = SymEngine::sec(2*@x)
92+
expect(f).to be_an_instance_of SymEngine::Sec
93+
expect(f.to_s).to eql("sec(2*x)")
94+
end
95+
end
6196
end
6297

6398
describe '#cot' do
@@ -67,6 +102,13 @@
67102
expect(f).to eql(1)
68103
end
69104
end
105+
context 'cot(2x)' do
106+
it 'is an instance of cot' do
107+
f = SymEngine::cot(2*@x)
108+
expect(f).to be_an_instance_of SymEngine::Cot
109+
expect(f.to_s).to eql("cot(2*x)")
110+
end
111+
end
70112
end
71113

72114
describe '#asin' do
@@ -76,6 +118,13 @@
76118
expect(f).to eql(@pi/2)
77119
end
78120
end
121+
context 'asin(2x)' do
122+
it 'is an instance of asin' do
123+
f = SymEngine::asin(2*@x)
124+
expect(f).to be_an_instance_of SymEngine::ASin
125+
expect(f.to_s).to eql("asin(2*x)")
126+
end
127+
end
79128
end
80129

81130
describe '#acos' do
@@ -85,6 +134,13 @@
85134
expect(f).to eql(0)
86135
end
87136
end
137+
context 'acos(2x)' do
138+
it 'is an instance of acos' do
139+
f = SymEngine::acos(2*@x)
140+
expect(f).to be_an_instance_of SymEngine::ACos
141+
expect(f.to_s).to eql("acos(2*x)")
142+
end
143+
end
88144
end
89145

90146
describe '#atan' do
@@ -94,6 +150,13 @@
94150
expect(f).to eql(@pi/4)
95151
end
96152
end
153+
context 'atan(2x)' do
154+
it 'is an instance of atan' do
155+
f = SymEngine::atan(2*@x)
156+
expect(f).to be_an_instance_of SymEngine::ATan
157+
expect(f.to_s).to eql("atan(2*x)")
158+
end
159+
end
97160
end
98161

99162
describe '#acsc' do
@@ -103,6 +166,13 @@
103166
expect(f).to eql(@pi/2)
104167
end
105168
end
169+
context 'acsc(2x)' do
170+
it 'is an instance of acsc' do
171+
f = SymEngine::acsc(2*@x)
172+
expect(f).to be_an_instance_of SymEngine::ACsc
173+
expect(f.to_s).to eql("acsc(2*x)")
174+
end
175+
end
106176
end
107177

108178
describe '#asec' do
@@ -112,6 +182,13 @@
112182
expect(f).to eql(0)
113183
end
114184
end
185+
context 'asec(2x)' do
186+
it 'is an instance of asec' do
187+
f = SymEngine::asec(2*@x)
188+
expect(f).to be_an_instance_of SymEngine::ASec
189+
expect(f.to_s).to eql("asec(2*x)")
190+
end
191+
end
115192
end
116193

117194
describe '#acot' do
@@ -121,6 +198,13 @@
121198
expect(f).to eql(@pi/4)
122199
end
123200
end
201+
context 'acot(2x)' do
202+
it 'is an instance of acot' do
203+
f = SymEngine::acot(2*@x)
204+
expect(f).to be_an_instance_of SymEngine::ACot
205+
expect(f.to_s).to eql("acot(2*x)")
206+
end
207+
end
124208
end
125209

126210
describe '#sinh' do
@@ -130,6 +214,13 @@
130214
expect(f).to eql(0)
131215
end
132216
end
217+
context 'sinh(2x)' do
218+
it 'is an instance of sinh' do
219+
f = SymEngine::sinh(2*@x)
220+
expect(f).to be_an_instance_of SymEngine::Sinh
221+
expect(f.to_s).to eql("sinh(2*x)")
222+
end
223+
end
133224
end
134225

135226
describe '#cosh' do
@@ -139,6 +230,13 @@
139230
expect(f).to eql(1)
140231
end
141232
end
233+
context 'cosh(2x)' do
234+
it 'is an instance of cosh' do
235+
f = SymEngine::cosh(2*@x)
236+
expect(f).to be_an_instance_of SymEngine::Cosh
237+
expect(f.to_s).to eql("cosh(2*x)")
238+
end
239+
end
142240
end
143241

144242
describe '#tanh' do
@@ -148,6 +246,13 @@
148246
expect(f).to eql(0)
149247
end
150248
end
249+
context 'tanh(2x)' do
250+
it 'is an instance of tanh' do
251+
f = SymEngine::tanh(2*@x)
252+
expect(f).to be_an_instance_of SymEngine::Tanh
253+
expect(f.to_s).to eql("tanh(2*x)")
254+
end
255+
end
151256
end
152257

153258
describe '#csch' do
@@ -157,6 +262,13 @@
157262
expect(f.to_s).to eql('csch(1)')
158263
end
159264
end
265+
context 'csch(2x)' do
266+
it 'is an instance of csch' do
267+
f = SymEngine::csch(2*@x)
268+
expect(f).to be_an_instance_of SymEngine::Csch
269+
expect(f.to_s).to eql("csch(2*x)")
270+
end
271+
end
160272
end
161273

162274
describe '#sech' do
@@ -166,6 +278,13 @@
166278
expect(f).to eql(1)
167279
end
168280
end
281+
context 'sech(2x)' do
282+
it 'is an instance of sech' do
283+
f = SymEngine::sech(2*@x)
284+
expect(f).to be_an_instance_of SymEngine::Sech
285+
expect(f.to_s).to eql("sech(2*x)")
286+
end
287+
end
169288
end
170289

171290
describe '#coth' do
@@ -175,6 +294,13 @@
175294
expect(f.to_s).to eql('coth(1)')
176295
end
177296
end
297+
context 'coth(2x)' do
298+
it 'is an instance of coth' do
299+
f = SymEngine::coth(2*@x)
300+
expect(f).to be_an_instance_of SymEngine::Coth
301+
expect(f.to_s).to eql("coth(2*x)")
302+
end
303+
end
178304
end
179305

180306
describe '#asinh' do
@@ -184,6 +310,13 @@
184310
expect(f).to eql(0)
185311
end
186312
end
313+
context 'asinh(2x)' do
314+
it 'is an instance of asinh' do
315+
f = SymEngine::asinh(2*@x)
316+
expect(f).to be_an_instance_of SymEngine::ASinh
317+
expect(f.to_s).to eql("asinh(2*x)")
318+
end
319+
end
187320
end
188321

189322
describe '#acosh' do
@@ -193,6 +326,13 @@
193326
expect(f).to eql(0)
194327
end
195328
end
329+
context 'acosh(2x)' do
330+
it 'is an instance of acosh' do
331+
f = SymEngine::acosh(2*@x)
332+
expect(f).to be_an_instance_of SymEngine::ACosh
333+
expect(f.to_s).to eql("acosh(2*x)")
334+
end
335+
end
196336
end
197337

198338
describe '#atanh' do
@@ -202,6 +342,13 @@
202342
expect(f).to eql(0)
203343
end
204344
end
345+
context 'atanh(2x)' do
346+
it 'is an instance of atanh' do
347+
f = SymEngine::atanh(2*@x)
348+
expect(f).to be_an_instance_of SymEngine::ATanh
349+
expect(f.to_s).to eql("atanh(2*x)")
350+
end
351+
end
205352
end
206353

207354
describe '#acsch' do
@@ -211,6 +358,13 @@
211358
expect(f.to_s).to eql('log(1 + 2**(1/2))')
212359
end
213360
end
361+
context 'acsch(2x)' do
362+
it 'is an instance of acsch' do
363+
f = SymEngine::acsch(2*@x)
364+
expect(f).to be_an_instance_of SymEngine::ACsch
365+
expect(f.to_s).to eql("acsch(2*x)")
366+
end
367+
end
214368
end
215369

216370
describe '#asech' do
@@ -220,6 +374,13 @@
220374
expect(f).to eql(0)
221375
end
222376
end
377+
context 'asech(2x)' do
378+
it 'is an instance of asech' do
379+
f = SymEngine::asech(2*@x)
380+
expect(f).to be_an_instance_of SymEngine::ASech
381+
expect(f.to_s).to eql("asech(2*x)")
382+
end
383+
end
223384
end
224385

225386
describe '#acoth' do
@@ -229,6 +390,13 @@
229390
expect(f.to_s).to eql('acoth(1)')
230391
end
231392
end
393+
context 'acoth(2x)' do
394+
it 'is an instance of acoth' do
395+
f = SymEngine::acoth(2*@x)
396+
expect(f).to be_an_instance_of SymEngine::ACoth
397+
expect(f.to_s).to eql("acoth(2*x)")
398+
end
399+
end
232400
end
233401

234402
describe '#lambertw' do
@@ -238,18 +406,30 @@
238406
expect(f).to eql(-1)
239407
end
240408
end
409+
context 'lambertw(2x)' do
410+
it 'is an instance of lambertw' do
411+
f = SymEngine::lambertw(2*@x)
412+
expect(f).to be_an_instance_of SymEngine::LambertW
413+
expect(f.to_s).to eql("lambertw(2*x)")
414+
end
415+
end
241416
end
242417

243418
describe '#zeta' do
244419
context 'calculation of zeta zero' do
245420
it 'returns minus half' do
246421
f = SymEngine::zeta(0)
247-
r1 = SymEngine::Integer.new(-1)
248-
r2 = SymEngine::Integer.new(2)
249-
r = r1/r2
422+
r = -1.quo(2)
250423
expect(f).to eql(r)
251424
end
252425
end
426+
context 'zeta(2x)' do
427+
it 'is an instance of zeta' do
428+
f = SymEngine::zeta(2*@x)
429+
expect(f).to be_an_instance_of SymEngine::Zeta
430+
expect(f.to_s).to eql("zeta(2*x, 1)")
431+
end
432+
end
253433
end
254434

255435
describe '#dirichlet_eta' do
@@ -259,6 +439,13 @@
259439
expect(f.to_s).to eql('log(2)')
260440
end
261441
end
442+
context 'dirichlet_eta(2x)' do
443+
it 'is an instance of dirichlet_eta' do
444+
f = SymEngine::dirichlet_eta(2*@x)
445+
expect(f).to be_an_instance_of SymEngine::Dirichlet_eta
446+
expect(f.to_s).to eql("dirichlet_eta(2*x)")
447+
end
448+
end
262449
end
263450

264451
describe '#gamma' do
@@ -268,6 +455,13 @@
268455
expect(f.to_s).to eql('1')
269456
end
270457
end
458+
context 'gamma(2x)' do
459+
it 'is an instance of gamma' do
460+
f = SymEngine::gamma(2*@x)
461+
expect(f).to be_an_instance_of SymEngine::Gamma
462+
expect(f.to_s).to eql("gamma(2*x)")
463+
end
464+
end
271465
end
272466

273467
end

0 commit comments

Comments
 (0)