def testNoFunctionIfNoPrivatePublicKeyword(self): concepts = parseConcepts("void helloWorld() ") self.assertNotIn(Concept.FUNCTION, concepts)
def testParseReturn(self): concepts = parseConcepts("return String();") self.assertIn(Concept.RETURN, concepts)
def testParseNewStatement(self): concepts = parseConcepts("String b = new String();") self.assertIn(Concept.OBJECT, concepts)
def testParseAssignmentFromEquals(self): concepts = parseConcepts("a = 2;") self.assertIn(Concept.ASSIGNMENT, concepts)
def testParseIfStatement(self): concepts = parseConcepts(" if (i == 5) {") self.assertIn(Concept.CONDITIONAL, concepts)
def testParseLessThan(self): concepts = parseConcepts("a = b < c;") self.assertIn(Concept.RELATIONAL_OP, concepts)
def testParseForWithNoSpaceBeforeParens(self): concepts = parseConcepts("for(int i = 0; i < 2; i++) {") self.assertIn(Concept.LOOP, concepts)
def testFunctionDeclarationOpeningParenNoSemicolon(self): concepts = parseConcepts("public void helloWorld() ") self.assertIn(Concept.FUNCTION, concepts)
def testParseLeftBracket(self): concepts = parseConcepts("int a = b[2];") self.assertIn(Concept.ARRAY, concepts)
def testNoParseIfFromVarName(self): concepts = parseConcepts("int iffy = 5;") self.assertNotIn(Concept.CONDITIONAL, concepts)
def testParseMinus(self): concepts = parseConcepts("a = b - c;") self.assertIn(Concept.ARITHMETIC_OP, concepts)
def testNoFunctionIfEndsWithSemicolon(self): concepts = parseConcepts("helloWorld(1, 2);") self.assertNotIn(Concept.FUNCTION, concepts)
def testParseSlash(self): concepts = parseConcepts("a = b / c;") self.assertIn(Concept.ARITHMETIC_OP, concepts)
def testParseRelOpAndArithOp(self): concepts = parseConcepts("a = (b > c + 5);") self.assertIn(Concept.RELATIONAL_OP, concepts) self.assertIn(Concept.ARITHMETIC_OP, concepts)
def testParseTimes(self): concepts = parseConcepts("a = b * c;") self.assertIn(Concept.ARITHMETIC_OP, concepts)
def testNoParseDoubleEqualsRelational(self): concepts = parseConcepts("if (a == 3) {") self.assertNotIn(Concept.ASSIGNMENT, concepts)
def testParseGreaterThan(self): concepts = parseConcepts("a = b > c;") self.assertIn(Concept.RELATIONAL_OP, concepts)
def testNoParseIfFromVarName(self): concepts = parseConcepts("int iffy = 5;"); self.assertNotIn(Concept.CONDITIONAL, concepts)
def testParseNotEquals(self): concepts = parseConcepts("a = b != c;") self.assertIn(Concept.RELATIONAL_OP, concepts)
def testParseForLoopAtStartOfLine(self): concepts = parseConcepts("for (int i = 0; i < 2; i++) {") self.assertIn(Concept.LOOP, concepts)
def testParseWhileLoop(self): concepts = parseConcepts("while(i > 0)") self.assertIn(Concept.LOOP, concepts)
def testNoParseForLoopFromVarname(self): concepts = parseConcepts("format = 2;") self.assertNotIn(Concept.LOOP, concepts)