Sha256: ed0efeeb45b40223e2d0cc2349e23c36ac0d4f00a36acedcab8a1fb256241d63

Contents?: true

Size: 1.96 KB

Versions: 48

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require "abstract_unit"

module ActionDispatch
  module Journey
    module NFA
      class TestTransitionTable < ActiveSupport::TestCase
        def setup
          @parser = Journey::Parser.new
        end

        def test_eclosure
          table = tt "/"
          assert_equal [0], table.eclosure(0)

          table = tt ":a|:b"
          assert_equal 3, table.eclosure(0).length

          table = tt "(:a|:b)"
          assert_equal 5, table.eclosure(0).length
          assert_equal 5, table.eclosure([0]).length
        end

        def test_following_states_one
          table = tt "/"

          assert_equal [1], table.following_states(0, "/")
          assert_equal [1], table.following_states([0], "/")
        end

        def test_following_states_group
          table  = tt "a|b"
          states = table.eclosure 0

          assert_equal 1, table.following_states(states, "a").length
          assert_equal 1, table.following_states(states, "b").length
        end

        def test_following_states_multi
          table  = tt "a|a"
          states = table.eclosure 0

          assert_equal 2, table.following_states(states, "a").length
          assert_equal 0, table.following_states(states, "b").length
        end

        def test_following_states_regexp
          table  = tt "a|:a"
          states = table.eclosure 0

          assert_equal 1, table.following_states(states, "a").length
          assert_equal 1, table.following_states(states, /[^\.\/\?]+/).length
          assert_equal 0, table.following_states(states, "b").length
        end

        def test_alphabet
          table = tt "a|:a"
          assert_equal [/[^\.\/\?]+/, "a"], table.alphabet

          table = tt "a|a"
          assert_equal ["a"], table.alphabet
        end

        private
          def tt(string)
            ast     = @parser.parse string
            builder = Builder.new ast
            builder.transition_table
          end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
jets-1.9.7 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.6 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.5 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.4 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.3 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.2 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.1 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.9.0 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.14 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.13 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.12 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.11 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.10 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.9 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.8 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.7 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.6 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.5 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.4 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb
jets-1.8.3 vendor/rails/actionpack/test/journey/nfa/transition_table_test.rb