Sha256: 586a5ead4794b07b78a41066ffe48ba8a841a2bc5527498bc245bec8b84b8297

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'test/unit'
require 'stamina/stamina_test'
module Stamina
  class Automaton
    # Tests Walking module on Automaton class
    class WalkingTestDfaDelta < StaminaTest

      DFA = Stamina::ADL::parse_automaton <<-EOF
        2 3
        0 true false
        1 false true
        0 1 a
        1 0 b
        1 1 a
      EOF
      S0 = DFA.ith_state(0)
      S1 = DFA.ith_state(1)

      def test_with_single_state_as_from
        assert_equal S1, DFA.dfa_delta(S0, 'a')
        assert_equal S1, DFA.dfa_delta(0, 'a')
        assert_equal S0, DFA.dfa_delta(1, 'b')
      end

      def test_with_single_array_as_from
        assert_equal [S1], DFA.dfa_delta([S0], 'a')
        assert_equal [S1], DFA.dfa_delta([0], 'a')
        assert_equal [S0], DFA.dfa_delta([1], 'b')
      end

      def test_with_multiple_array_as_from
        assert_equal [S1], DFA.dfa_delta([S0, S1], 'a')
        assert_equal [S1], DFA.dfa_delta([0, 1], 'a')
        assert_equal [S0], DFA.dfa_delta([0, 1], 'b')
      end

    end # class WalkingTestDfaDelta
  end # class Automaton
end # module Stamina

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stamina-0.4.0 test/stamina/automaton/walking/dfa_delta_test.rb