Sha256: 5a8e3ecfa2658570333f13b510730d3282e9901acd7a12b3f60b912644114661

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe Danica::Expression::Gauss do
  let(:variables) do
    {
      x: :x,
      average: :u,
      variance_root: { latex: '\theta', gnuplot: :v }
    }
  end

  subject { described_class::Gauss.new(variables) }
  it_behaves_like 'an object that respond to basic_methods'

  describe '#to_tex' do
    context 'when creating the spatial operator for constantly accelerated movement' do
      let(:expected) { '\frac{1}{\theta \cdot \sqrt{2 \cdot \pi}} \cdot e^{-\frac{\left(x -u\right)^{2}}{2 \cdot \theta^{2}}}'  }

      it 'return the latex format CAM' do
        expect(subject.to_tex).to eq(expected)
      end
    end
  end

  describe '#to_gnu' do
    context 'when creating the spatial operator for constantly accelerated movement' do
      let(:expected) { '(1)/(v * sqrt(2 * pi)) * exp(-((x -u)**(2))/(2 * v**(2)))' }

      it 'return the gnu format CAM' do
        expect(subject.to_gnu).to eq(expected)
      end
    end
  end

  context 'when not passing variables' do
    subject { described_class::Gauss.new }

    describe '#to_tex' do
      let(:expected) { '\frac{1}{\sigma \cdot \sqrt{2 \cdot \pi}} \cdot e^{-\frac{\left(x -\mu\right)^{2}}{2 \cdot \sigma^{2}}}'  }

      it 'rely on default variables definition' do
        expect(subject.to_tex).to eq(expected)
      end
    end

    describe '#to_gnu' do
      let(:expected) { '(1)/(v * sqrt(2 * pi)) * exp(-((x -u)**(2))/(2 * v**(2)))' }

      it 'rely on default variables definition' do
        expect(subject.to_gnu).to eq(expected)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danica-2.7.4 spec/lib/danica/expression/gauss_spec.rb
danica-2.7.3 spec/lib/danica/expression/gauss_spec.rb
danica-2.7.2 spec/lib/danica/expression/gauss_spec.rb
danica-2.7.1 spec/lib/danica/expression/gauss_spec.rb