def test_var1__ok(self): patt = pattern.BasicLinePattern(' push $1 ') self.assertEqual(patt.vars, {'$1'}) self.assertEqual(patt.line, 'push $1') self.assertEqual(patt.output, ['push', ' ', '$1'])
def test_parse_comma_correctly(self): patt = pattern.BasicLinePattern(' ld $1, a') self.assertEqual(patt.vars, {'$1'}) self.assertEqual(patt.line, r'ld $1, a') self.assertEqual(patt.output, ['ld', ' ', '$1', ',', ' ', 'a'])
def test_var_and_double_dollar(self): patt = pattern.BasicLinePattern(' $2$$$1 ') self.assertEqual(patt.vars, {'$2', '$1'}) self.assertEqual(patt.line, '$2$$$1') self.assertEqual(patt.output, ['$2', '$', '$1'])
def test_slash(self): patt = pattern.BasicLinePattern(r' \$1') self.assertEqual(patt.vars, {'$1'}) self.assertEqual(patt.line, r'\$1') self.assertEqual(patt.output, ['\\', '$1'])
def test_no_var_double_dollar(self): patt = pattern.BasicLinePattern(' $$1 ') self.assertEqual(patt.vars, set()) self.assertEqual(patt.line, '$$1') self.assertEqual(patt.output, ['$', '1'])