def test_has_more_commands(self): file_path = './add/Add.asm' test_parser = Parser(file_path) test_parser.process_file() self.assertTrue(test_parser.hasMoreCommands()) test_parser.line_counter = test_parser.length - test_parser.length self.assertTrue(test_parser.hasMoreCommands()) test_parser.line_counter = test_parser.length - 1 self.assertFalse(test_parser.hasMoreCommands()) test_parser.line_counter = test_parser.length self.assertFalse(test_parser.hasMoreCommands()) test_parser.line_counter = test_parser.length + 1 self.assertFalse(test_parser.hasMoreCommands())
def test_hasMoreCommands(self): testParser = Parser( '/Users/Sean/Desktop/nand2tetris/projects/06/add/Add.asm') self.assertTrue( testParser.hasMoreCommands()) # Line 1 - should be true testParser.advance() self.assertTrue( testParser.hasMoreCommands()) # Line 2 - should be true testParser.advance() testParser.advance() self.assertTrue( testParser.hasMoreCommands()) # Line 4 - should be true testParser.advance() testParser.advance() self.assertFalse( testParser.hasMoreCommands()) # Line 6 - should be false