def test_match_blocks(self):
   statements = ifelse.record_blocks(self.test_file)
   self.assertEqual(ifelse.IfElseStatement.ignored_count(statements), self.answers['ignore_count'])
   self.assertEqual(ifelse.IfElseStatement.correct_count(statements), self.answers['correct_count'])
   self.assertEqual(sorted([S.line for S in ifelse.IfElseStatement.ignored(statements)]),
                    sorted(self.answers['ignored_lines']))
   self.assertEqual(sorted([S.line for S in ifelse.IfElseStatement.correct(statements)]),
                    sorted(self.answers['correct_lines']))
 def test_aosp_sources(self):
   for i, java_file in enumerate(glob.glob(os.path.join(TESTING_INPUTS, "ifelse", "*.java"))):
     contents = open(java_file, 'rU').read()
     statements = ifelse.record_blocks(contents)
     filename = os.path.basename(java_file)
     if not self.answers.has_key(filename):
       continue
     answers = self.answers[filename]
     ignored_count = ifelse.IfElseStatement.ignored_count(statements)
     self.assertEqual(ignored_count, answers['ignored_count'])
     if ignored_count > 0:
       self.assertEqual(sorted([S.line for S in ifelse.IfElseStatement.ignored(statements)]),
                        sorted(answers['ignored_lines']))
     self.assertEqual(ifelse.IfElseStatement.correct_count(statements), answers['correct_count'])
     self.assertEqual(sorted([S.line for S in ifelse.IfElseStatement.correct(statements)]),
                      sorted(answers['correct_lines']))
     if answers.has_key('correct_alternative_count'):
       self.assertEqual([len(S.alternatives) for S in ifelse.IfElseStatement.correct(statements)],
                        answers['correct_alternative_count'])