Sha256: e8138ff093163933657763114540e692b953703bec60d2014716d4948e223412

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Dydx:Function do
  # TODO: refactor
  it{ expect(f(x, y)).to eq(f(x, y)) }
  it{ expect(f(x, y)).to eq($f) }
  it{ expect(f(x, y).algebra).to be_nil }
  it{ expect(f(x, y).vars).to eq([:x, :y]) }
  it{ expect{f(x, y, z)}.to raise_error(ArgumentError) }
  it{ expect{f(x)}.to raise_error(ArgumentError) }
  it{ expect(f(x, y) <= x * y ).to eq(f(x, y)) }
  it{ expect(f(x, y)).to eq(f(x, y)) }
  it{ expect(f(x, y)).to eq($f) }
  it{ expect(f(x, y).algebra).to eq(x * y) }
  it{ expect(f(x, y)).to eq(x * y) }
  it{ expect(eval(f(x, y).to_s)).to eq(f(x, y)) }
  it{ expect(f(x, y)).to eq(eval(f(x, y).to_s)) }
  it{ expect(f(a, b)).to eq(a * b) }
  it{ expect(f(2, 3)).to eq(6) }
  it{ expect(f(a + b, c)).to eq((a + b) * c) }
  it{ expect(d/dx(f(x, y))).to eq(y) }
  it{ expect(d/dy(f(x, y))).to eq(x) }
  it{ expect(d/dz(f(x, y))).to eq(0) }

  it{ expect(g(a, b) <= f(a + b, b)).to eq(g(a, b)) }
  it{ expect(g(a, b)).to eq($g) }
  it{ expect(g(2, 3)).to eq(15) }

  it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq(h(a, b, c)) }
  it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq($h) }
  it{ expect(h(a, b, c)).to eq(( a + ( 2 * b ) )) }
  it{ expect(h(a, b, c).algebra).to eq(( a + ( 2 * b ) )) }

  it 'ex.4' do
    $f = nil
    f(x) <= log(x)
    expect(f(a)).to eq(log(a))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dydx-0.1.31 spec/lib/function_spec.rb
dydx-0.1.3 spec/lib/function_spec.rb
dydx-0.1.29 spec/lib/function_spec.rb