コード例 #1
0
   def testOverwriteExistingTransitions(self):
      s = epsilon_nfa._State()
      s1 = epsilon_nfa._State()

      s.addTransition("f", s1)
      self.assertEqual(s.transitions("f"), frozenset([s1]))

      s.addTransition("f", s1)
      self.assertEqual(s.transitions("f"), frozenset([s1]))
コード例 #2
0
   def testEpsilonTransitions(self):
      s = epsilon_nfa._State()
      s1 = epsilon_nfa._State()
      s2 = epsilon_nfa._State()

      s.addTransition(None, s1)
      self.assertEqual(s.transitions(None), frozenset([s1]))
      self.assertEqual(s.epsilonTransitions(), frozenset([s1]))

      s.addEpsilonTransition(s2)
      self.assertEqual(s.transitions(None), frozenset([s1, s2]))
      self.assertEqual(s.epsilonTransitions(), frozenset([s1, s2]))
コード例 #3
0
   def testAddMultipleTransitions(self):
      s = epsilon_nfa._State()
      s1 = epsilon_nfa._State()
      s2 = epsilon_nfa._State()
      s3 = epsilon_nfa._State()
      s4 = epsilon_nfa._State()

      s.addTransition("f", s1)
      s.addTransition("f", s2)
      s.addTransition("f", s4)
      s.addTransition("0", s3)

      self.assertEqual(s.transitions("f"), frozenset([s1, s2, s4]))
      self.assertEqual(s.transitions("0"), frozenset([s3]))
コード例 #4
0
   def testCreate(self):
      s = epsilon_nfa._State()
      self.assert_(not s.transitions("a"))
      self.assert_(not s.transitions("3"))
      self.assert_(not s.transitions("\n"))

      self.assertEqual(s.transitions("a"), frozenset())
コード例 #5
0
   def setUp(self):
      self.s6 = epsilon_nfa._State()

      self.s5 = epsilon_nfa._State()
      self.s5.addEpsilonTransition(self.s6)

      self.s4 = epsilon_nfa._State()
      self.s4.addTransition("c", self.s5)

      self.s3 = epsilon_nfa._State()
      self.s3.addEpsilonTransition(self.s4)

      self.s2 = epsilon_nfa._State()
      self.s2.addEpsilonTransition(self.s3)
      self.s2.addEpsilonTransition(self.s4)

      self.s1 = epsilon_nfa._State()
      self.s1.addEpsilonTransition(self.s2)
      self.s1.addTransition("a", self.s3)
コード例 #6
0
 def testSetNullTransitionState(self):
    s = epsilon_nfa._State()
    self.assertRaises(TypeError, s.addTransition, "X", None)
コード例 #7
0
   def testAddLoopTransition(self):
      s = epsilon_nfa._State()

      s.addTransition("a", s)
      self.assertEqual(s.transitions("a"), frozenset([s]))
コード例 #8
0
   def testAddSingleTransition(self):
      s = epsilon_nfa._State()
      s1 = epsilon_nfa._State()

      s.addTransition("a", s1)
      self.assertEqual(s.transitions("a"), frozenset([s1]))