Exemplo n.º 1
0
 def test_nested(self):
     ''' > Expand strings in nested trees '''
     trees = [(('"hi"',),),(('"hi"',),),('set','a',('+','a','"hi"')),('set','a',('+','a','"hi"'))]
     for ast in trees:
         with self.subTest(ast=ast):
             est = psll.expand_string_literals(ast)
             self.assertGreater(depth(est),depth(ast))
Exemplo n.º 2
0
 def test_string_expansion(self):
     ''' > Make sure the prompt is expanded '''
     prompts = (random_string(N+1) for N in range(10))
     for prompt in prompts:
         with self.subTest(prompt=prompt):
             ast = (f'"{prompt}"',)
             est = psll.expand_string_literals(ast)
             self.assertGreater(depth(est),depth(ast))
Exemplo n.º 3
0
 def test_quote_combinations(self):
     ''' > Expand some more strings as subtrees '''
     trees = [('"hi"',),('out','"hi"'),('"one"','"two"'),
         ('set','a','"hello"'),('set','"a"','hello'),
         ('"set"','a','hello')]
     for ast in trees:
         with self.subTest(ast=ast):
             est = psll.expand_string_literals(ast)
             self.assertGreater(depth(est),depth(ast))
Exemplo n.º 4
0
 def test_double_quote(self):
     ''' > Make sure the " sign is *not* is expanded when escaped '''
     ast = ('\\"',)
     est = psll.expand_string_literals(ast)
     self.assertEqual(ast,est)
Exemplo n.º 5
0
 def test_empty(self):
     ''' > Empty string expands to 'eps' '''
     ast = ('""',)
     target = (('eps',),)
     self.assertEqual(psll.expand_string_literals(ast),target)