def test_when_adding_a_left_bracket_to_a_value_a_pre_state_shoud_change_to_subject_state( self): test_string = "print(" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_SUBJ)
def test_when_adding_characters_beside_right_bracket_to_value_in_subject_state_should_stay_in_subject_state( self): test_string = "print(test" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_SUBJ)
def test_when_char_does_not_start_with_a_letter_state_should_be_new_group( self): test_string = "(" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_NEW_GROUP)
def test_when_value_started_with_a_letter_and_is_followed_by_letters_state_should_stay_in_pre( self): test_string = "pr" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_PRE)
def test_when_adding_letters_to_value_in_op_state_should_change_to_prefix( self): test_string = "print(test)|do" parse = ApplyRules(test_string) parse.run() print(parse.current_group.rule_count) self.assertEqual(parse.current_state, S_PRE)
def test_when_adding_right_bracket_to_value_in_end_rule_state_should_change_to_end_group( self): test_string = "print(test))" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_END_GROUP)
def test_when_adding_or_operators_to_value_in_end_rule_state_should_change_to_op( self): test_string = "print(test)|" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_OP)
def test_when_first_char_is_a_letter_state_should_move_to_pre(self): test_string = "p" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_PRE)
def test_when_value_reach_an_op_state_rule_count_should_increate_by_one( self): test_string = "print(1)|" parse = ApplyRules(test_string) parse.run() self.assertEqual(parse.current_group.rule_count, 2)
def test_arrival_to_NEW_GROUP(self): str = "a = (132) & (" parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: NEW_GROUP")
def test_the_first_state_for_all_cases_should_be_new_group_state(self): test_string = "" parse = ApplyRules(test_string) parse.run() print(parse.current_state) self.assertEqual(parse.current_state, S_NEW_GROUP)
def test_PREFIX_loop(self): str = "a = 1" parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: PREFIX")
def test_arrival_to_END_GROUP_after_END_RULE(self): str = "a = ( (132) ) " parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: END_GROUP")
def test_arrival_to_OPERATOR_after_END_GROUP(self): str = "a = ( (132) )&" parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: OPERATOR")
def test_arrival_to_PREFIX_after_OPERATOR(self): str = "a = (132) & z" parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: PREFIX")
def test_when_value_has_not_reach_op_state_yet_rule_count_should_be_one( self): test_string = "" parse = ApplyRules(test_string) parse.run() self.assertEqual(parse.current_group.rule_count, 1)
def test_SUBJECT_loop(self): str = "a = (132" parse = ApplyRules(str) parse.run() self.assertEqual(parse.current_state, "STATE: SUBJECT")