def test_compile_class_var_dec(self): engine = CompilationEngine("field int direction;", "fakeOutputFile", True) engine.compile_class_var_dec() self.assertEqual(engine.output, [ '<classVarDec>', '<keyword> field </keyword>', '<keyword> int </keyword>', '<identifier> direction </identifier>', '<symbol> ; </symbol>', '</classVarDec>' ])
def test_compile_class_var_dec(self): engine = CompilationEngine("field int direction;", "fakeOutputFile", True) engine.compile_class_var_dec() self.assertEqual(engine.xml_output, [ '<classVarDec>', '<keyword> field </keyword>', '<keyword> int </keyword>', '<identifier> direction, category: field, definedOrUsed: defined, index: 0 </identifier>', '<symbol> ; </symbol>', '</classVarDec>'])
def test_compile_class_var_dec_2(self): engine = CompilationEngine("static int directionA, directionB;", "fakeOutputFile", True) engine.compile_class_var_dec() self.assertEqual(engine.xml_output, [ '<classVarDec>', '<keyword> static </keyword>', '<keyword> int </keyword>', '<identifier> directionA, category: static, definedOrUsed: defined, index: 0 </identifier>', '<symbol> , </symbol>', '<identifier> directionB, category: static, definedOrUsed: defined, index: 1 </identifier>', '<symbol> ; </symbol>', '</classVarDec>'])
def test_compile_do_2(self): engine = CompilationEngine("field Square square; do square.dispose();", "fakeOutputFile", True) engine.compile_class_var_dec() engine.compile_do() self.assertEqual(engine.xml_output, [ '<classVarDec>', '<keyword> field </keyword>', '<identifier> Square, category: class, definedOrUsed: used </identifier>', '<identifier> square, category: field, definedOrUsed: defined, index: 0 </identifier>', '<symbol> ; </symbol>', '</classVarDec>', '<doStatement>', '<keyword> do </keyword>', '<identifier> square, category: field, definedOrUsed: used, index: 0 </identifier>', '<symbol> . </symbol>', '<identifier> dispose, category: subroutine, definedOrUsed: used </identifier>', '<symbol> ( </symbol>', '<expressionList>', '</expressionList>', '<symbol> ) </symbol>', '<symbol> ; </symbol>', '</doStatement>'])