예제 #1
0
def test_eq_other(test_case_mock, variable_reference_mock):
    statement_1 = astmt.AssignmentStatement(
        test_case_mock, variable_reference_mock, variable_reference_mock
    )
    statement_2 = astmt.AssignmentStatement(
        test_case_mock, variable_reference_mock, variable_reference_mock
    )
    assert statement_1.__eq__(statement_2)
예제 #2
0
def test_accept(test_case_mock, variable_reference_mock):
    statement = astmt.AssignmentStatement(test_case_mock,
                                          variable_reference_mock,
                                          variable_reference_mock)
    visitor = MagicMock()
    statement.accept(visitor)
    visitor.visit_assignment_statement.assert_called_with(statement)
예제 #3
0
def test_assignment_statement_clone():
    test_case = dtc.DefaultTestCase()
    int_prim = prim.IntPrimitiveStatement(test_case, 5)
    int_prim2 = prim.IntPrimitiveStatement(test_case, 10)
    # TODO(fk) the assignment statement from EvoSuite might not be fitting for our case?
    # Because currently we can only overwrite existing values?
    assignment_stmt = assign.AssignmentStatement(test_case, int_prim.ret_val,
                                                 int_prim2.ret_val)
    test_case.add_statement(int_prim)
    test_case.add_statement(int_prim2)
    test_case.add_statement(assignment_stmt)

    cloned = test_case.clone()
    assert isinstance(cloned.statements[2], assign.AssignmentStatement)
    assert cloned.statements[2] is not assignment_stmt
예제 #4
0
def test_eq_other_type(test_case_mock, variable_reference_mock):
    statement = astmt.AssignmentStatement(test_case_mock,
                                          variable_reference_mock,
                                          MagicMock(vri.VariableReferenceImpl))
    assert not statement.__eq__(test_case_mock)
예제 #5
0
def test_hash(test_case_mock, variable_reference_mock):
    statement = astmt.AssignmentStatement(test_case_mock,
                                          variable_reference_mock,
                                          MagicMock(vri.VariableReferenceImpl))
    assert statement.__hash__() != 0
예제 #6
0
def test_field_statement(test_case_mock, variable_reference_mock):
    rhs = MagicMock(vri.VariableReferenceImpl)
    field_statement = astmt.AssignmentStatement(test_case_mock,
                                                variable_reference_mock, rhs)
    assert field_statement._rhs == rhs
예제 #7
0
def test_get_variable_references(test_case_mock):
    ret_val = MagicMock(vri.VariableReferenceImpl)
    rhs = MagicMock(vri.VariableReferenceImpl)
    statement = astmt.AssignmentStatement(test_case_mock, ret_val, rhs)
    result = statement.get_variable_references()
    assert result == {ret_val, rhs}
예제 #8
0
def assignment_statement(test_case_mock, variable_reference_mock):
    return astmt.AssignmentStatement(
        test_case_mock, variable_reference_mock, MagicMock(vri.VariableReferenceImpl)
    )