Sha256: 23af4f911d234aca25dd9b43e77898fc542db60d923e5e9bb1224750286bbca2

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(( ( 2 * b ) + a )) }
  it{ expect(h(a, b, c).algebra).to eq(( ( 2 * b ) + a )) }

  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.28 spec/lib/function_spec.rb
dydx-0.1.25 spec/lib/function_spec.rb
dydx-0.1.2 spec/lib/function_spec.rb