Sha256: cf944a97a38d1570d50f5b4bd766e03b37dbc339e474431cf3a070368aaaf7d2

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

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

  context 'ex2' do
    $b = (:x ^ (:x * 2))
    let(:d1){ db/dx }
    let(:d2){ d/dx($b) }
    it{ expect(d1.to_s).to eq('( ( x * 2 ) * ( x ^ ( ( x * 2 ) - 1 ) ) )') }
    it{ expect(d2.to_s).to eq('( ( x * 2 ) * ( x ^ ( ( x * 2 ) - 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
    $f = 2 * (e ^ (2 * :z))
    let(:d1){ df/dz }
    let(:d2){ d/dz($f) }
    it{ expect(d1.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') }
    it{ expect(d2.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') }
  end

  context 'ex5' do
    $f = 2 * (e ^ (2 * z))
    let(:d1){ df/dz }
    let(:d2){ d/dz($f) }
    it{ expect(d1.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') }
    it{ expect(d2.to_s).to eq('( 4 * ( e ^ ( 2 * z ) ) )') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dydx-0.0.9 spec/dydx_spec.rb