Sha256: 1a200dacb21b00abb7fb4e24cf9381c4c8caeae1f88cf883e571afff8db3cad7

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

describe Automaton do
  context "with a simple table" do
    let(:states) { [ :s1, :s2 ] }
    let(:alphabet) { [0, 1] }
    let(:accept) { [ :s1 ] }
    let(:transitions) { {
      :s1 => { 0 => :s2, 1 => :s1 },
      :s2 => { 0 => :s1, 1 => :s2 }
    } }

    subject do
      Automaton.new(states, alphabet, :s1, accept, transitions)
    end

    it "basically runs" do
      expect(subject.run([1, 1])).to be_truthy
    end

    it "yields for transitions" do
      expect { |b| subject.run([1], &b) }.to yield_control
    end

    it "runs fast" do
      expect(benchmark do
        subject.run([1, 1])
      end).to be < 5e-5
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
antelope-0.1.1 spec/antelope/automaton_spec.rb
antelope-0.1.0 spec/antelope/automaton_spec.rb
antelope-0.0.1 spec/antelope/automaton_spec.rb