예제 #1
0
파일: test.py 프로젝트: howiemac/evoke
 def testNextSiblingNoOther(self):
     """when there are no siblings, 
    expect next_sibling to return None"""
     here = outer_token = Token()
     token = Token(indent=2)
     here = here.consume(token)
     self.assertFalse(token.next_sibling())
예제 #2
0
파일: test.py 프로젝트: howiemac/evoke
 def testNextSiblingNoOther(self):
     """when there are no siblings, 
    expect next_sibling to return None"""
     here = outer_token = Token()
     token = Token(indent=2)
     here = here.consume(token)
     self.assertFalse(token.next_sibling())
예제 #3
0
파일: test.py 프로젝트: howiemac/evoke
 def testConsumeCall(self):
     "render a token structure.  Expect an empty string"
     here = outer_token = Token()
     for i in range(3):
         token = Token(indent=i * 2)
         here = here.consume(token)
     self.assertEqual(outer_token({}), '')
예제 #4
0
파일: test.py 프로젝트: howiemac/evoke
 def testConsumeHigherIndent3Levels(self):
     "The inner tokens will be in the outer token's content"
     here = outer_token = Token()
     for i in range(3):
         token = Token(indent=i * 2)
         here = here.consume(token)
     self.assertEqual(here.parent.parent.parent, outer_token)
예제 #5
0
파일: test.py 프로젝트: howiemac/evoke
 def testConsumeBadDedent(self):
     "try to add a token with an invalid indent."
     here = outer_token = Token()
     for i in range(3):
         token = Token(indent=i * 2)
         here = here.consume(token)
     # indent -1 0 2 4
     token = Token(indent=1)
     self.assertRaises(EvoIndentationError, here.consume, token)
예제 #6
0
파일: test.py 프로젝트: howiemac/evoke
 def testConsumeCorrectDedentToZero(self):
     "add a correctly dedented token"
     here = outer_token = Token()
     for i in range(3):
         token = Token(indent=i * 2)
         here = here.consume(token)
     # indent -1 0 2 4
     token = Token(indent=0)
     here = here.consume(token)
     self.assertIn(token, outer_token.content)
예제 #7
0
파일: test.py 프로젝트: howiemac/evoke
 def testNextSibling(self):
     """for the last sibling   
    expect next_sibling to return None"""
     here = outer_token = Token()
     token1 = Token(indent=2)
     token2 = Token(indent=2)
     token3 = Token(indent=2)
     here = here.consume(token1)
     here = here.consume(token2)
     here = here.consume(token3)
     # first returns second; second returns third
     self.assertEqual(token1.next_sibling(), token2)
     self.assertEqual(token2.next_sibling(), token3)
     # last in the queue
     self.assertFalse(token3.next_sibling())
예제 #8
0
파일: test.py 프로젝트: howiemac/evoke
 def testCreateToken(self):
     ""
     token = Token()
     self.assertFalse(token.parent)
     self.assertEqual(token.content, [])
     self.assertEqual(token.indent, -1)
     self.assertEqual(token.filename, '')
     self.assertEqual(token.line, 0)
예제 #9
0
파일: test.py 프로젝트: howiemac/evoke
 def testNextSibling(self):
     """for the last sibling   
    expect next_sibling to return None"""
     here = outer_token = Token()
     token1 = Token(indent=2)
     token2 = Token(indent=2)
     token3 = Token(indent=2)
     here = here.consume(token1)
     here = here.consume(token2)
     here = here.consume(token3)
     # first returns second; second returns third
     self.assertEqual(token1.next_sibling(), token2)
     self.assertEqual(token2.next_sibling(), token3)
     # last in the queue
     self.assertFalse(token3.next_sibling())