spec/dydx_spec.rb in dydx-0.1.3 vs spec/dydx_spec.rb in dydx-0.1.4

- old
+ new

@@ -3,37 +3,18 @@ describe Dydx do it 'has a version number' do expect(Dydx::VERSION).not_to be nil end - context 'ex1' do - $a = (:x ^ :n) - let(:d1){ da/dx } - let(:d2){ d/dx($a) } - it{ expect(d1.to_s).to eq('( n * ( x ^ ( n - 1 ) ) )') } - it{ expect(d2.to_s).to eq('( n * ( x ^ ( n - 1 ) ) )') } - end + it 'demo' do + f(x, y) <= x + x * y + y + expect(f(x, y)).to eq(x * (1 + y) + y) + expect(f(a, 2)).to eq(3 * a + 2) + expect(f(1, a + b)).to eq(1 + 2 * ( a + b )) + expect(f(1, 2)).to eq(5) + expect(d/dx(f(x, y))).to eq(1 + y) - context 'ex2' do - $b = (:x ^ (:x * 2)) - let(:d1){ db/dx } - let(:d2){ d/dx($b) } - it{ expect(d1.to_s).to eq('( ( 2 * x ) * ( x ^ ( ( 2 * x ) - 1 ) ) )') } - it{ expect(d2.to_s).to eq('( ( 2 * x ) * ( x ^ ( ( 2 * x ) - 1 ) ) )') } - end - - context 'ex3' do - $c = (:t ^ 2) / 2 - let(:d1){ dc/dt } - let(:d2){ d/dt($c) } - it{ expect(d1.to_s).to eq('t') } - it{ expect(d2.to_s).to eq('t') } - end - - context 'ex4' do - $i = 2 * (e ^ (2 * :z)) - let(:d1){ di/dz } - let(:d2){ d/dz($i) } - it{ expect(d1.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') } - it{ expect(d2.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') } + g(x) <= sin(x) + expect(d/dx(g(x))).to eq(cos(x)) + expect(S(g(x), dx)[0, pi / 2]).to eq(1.0) end end