def testAtomicLabel(self):
    """Tests an atomic label passes unchanged."""

    # 'a'  =>  'a'

    node1 = ( 'a', [ None ] )
    source = [ node1 ]
    self.assertEqual(make_dafsa.reverse(source), source)
Beispiel #2
0
  def testAtomicLabel(self):
    """Tests an atomic label passes unchanged."""

    # 'a'  =>  'a'

    node1 = ( 'a', [ None ] )
    source = [ node1 ]
    self.assertEqual(make_dafsa.reverse(source), source)
Beispiel #3
0
  def testLabel(self):
    """Tests that labels are reversed."""

    # 'ab'  =>  'ba'

    node1 = ( 'ab', [ None ] )
    source1 = [ node1 ]
    node2 = ( 'ba', [ None ] )
    source2 = [ node2 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
  def testLabel(self):
    """Tests that labels are reversed."""

    # 'ab'  =>  'ba'

    node1 = ( 'ab', [ None ] )
    source1 = [ node1 ]
    node2 = ( 'ba', [ None ] )
    source2 = [ node2 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
Beispiel #5
0
  def testChain(self):
    """Tests that edges are reversed."""

    # 'a' -> 'b'  =>  'b' -> 'a'

    node2 = ( 'b', [ None ] )
    node1 = ( 'a', [ node2 ] )
    source1 = [ node1 ]
    node4 = ( 'a', [ None ] )
    node3 = ( 'b', [ node4 ] )
    source2 = [ node3 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
  def testChain(self):
    """Tests that edges are reversed."""

    # 'a' -> 'b'  =>  'b' -> 'a'

    node2 = ( 'b', [ None ] )
    node1 = ( 'a', [ node2 ] )
    source1 = [ node1 ]
    node4 = ( 'a', [ None ] )
    node3 = ( 'b', [ node4 ] )
    source2 = [ node3 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
Beispiel #7
0
  def testInnerTerminator(self):
    """Tests a sequence with an inner terminator can be reversed."""

    # 'a' -> 'b'    'b' -> 'a'
    #   \       =>         /
    #  {sink}        ------

    node2 = ( 'b', [ None ] )
    node1 = ( 'a', [ node2, None ] )
    source1 = [ node1 ]
    node4 = ( 'a', [ None ] )
    node3 = ( 'b', [ node4 ] )
    source2 = [ node3, node4 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
  def testInnerTerminator(self):
    """Tests a sequence with an inner terminator can be reversed."""

    # 'a' -> 'b'    'b' -> 'a'
    #   \       =>         /
    #  {sink}        ------

    node2 = ( 'b', [ None ] )
    node1 = ( 'a', [ node2, None ] )
    source1 = [ node1 ]
    node4 = ( 'a', [ None ] )
    node3 = ( 'b', [ node4 ] )
    source2 = [ node3, node4 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
Beispiel #9
0
  def testReverseAtomicTrie(self):
    """Tests a reverse trie formed DAFSA can be reversed."""

    # 'a'          'a'
    #   \          /
    #   'c'  =>  'c'
    #   /          \
    # 'b'          'b'

    node3 = ( 'c', [ None ] )
    node2 = ( 'b', [ node3 ] )
    node1 = ( 'a', [ node3 ] )
    source1 = [ node1, node2 ]
    node6 = ( 'b', [ None ] )
    node5 = ( 'a', [ None ] )
    node4 = ( 'c', [ node5, node6 ] )
    source2 = [ node4 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
  def testReverseAtomicTrie(self):
    """Tests a reverse trie formed DAFSA can be reversed."""

    # 'a'          'a'
    #   \          /
    #   'c'  =>  'c'
    #   /          \
    # 'b'          'b'

    node3 = ( 'c', [ None ] )
    node2 = ( 'b', [ node3 ] )
    node1 = ( 'a', [ node3 ] )
    source1 = [ node1, node2 ]
    node6 = ( 'b', [ None ] )
    node5 = ( 'a', [ None ] )
    node4 = ( 'c', [ node5, node6 ] )
    source2 = [ node4 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
Beispiel #11
0
  def testDiamond(self):
    """Tests we can reverse both edges and nodes in a diamond."""

    #   'cd'           'dc'
    #   /  \           /  \
    # 'ab' 'gh'  =>  'hg' 'ba'
    #   \  /           \  /
    #   'ef'           'fe'

    node4 = ( 'gh', [ None ] )
    node3 = ( 'ef', [ node4 ] )
    node2 = ( 'cd', [ node4 ] )
    node1 = ( 'ab', [ node2, node3 ] )
    source1 = [ node1 ]
    node8 = ( 'ba', [ None ] )
    node7 = ( 'fe', [ node8 ] )
    node6 = ( 'dc', [ node8 ] )
    node5 = ( 'hg', [ node6, node7 ] )
    source2 = [ node5 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)
  def testDiamond(self):
    """Tests we can reverse both edges and nodes in a diamond."""

    #   'cd'           'dc'
    #   /  \           /  \
    # 'ab' 'gh'  =>  'hg' 'ba'
    #   \  /           \  /
    #   'ef'           'fe'

    node4 = ( 'gh', [ None ] )
    node3 = ( 'ef', [ node4 ] )
    node2 = ( 'cd', [ node4 ] )
    node1 = ( 'ab', [ node2, node3 ] )
    source1 = [ node1 ]
    node8 = ( 'ba', [ None ] )
    node7 = ( 'fe', [ node8 ] )
    node6 = ( 'dc', [ node8 ] )
    node5 = ( 'hg', [ node6, node7 ] )
    source2 = [ node5 ]
    self.assertEqual(make_dafsa.reverse(source1), source2)