Skip to content

Failed requirements in cast functions #1994

Open
@CaelmBleidd

Description

@CaelmBleidd

Description

Sometimes requirement inside of the cast function in the engine fails.

To Reproduce

Steps to reproduce the behavior:

  1. Create a project with following code:
public interface VirtualInvokeInterface<T1, T2> {
    int narrowParameterTypeInInheritorObjectCast(T1 object);

    int narrowParameterTypeInInheritorArrayCast(T2 object);
}

public class VirtualInvokeClass implements VirtualInvokeInterface<Integer, byte[]> {
    @Override
    public final int narrowParameterTypeInInheritorObjectCast(Integer object) {
        if (object == null) {
            return 0;
        }

        if (object == 1) {
            return 1;
        }

        return object;
    }

    @Override
    public final int narrowParameterTypeInInheritorArrayCast(byte[] object) {
        if (object == null) {
            return 0;
        }

        return object[0];
    }
}

public class Example {
    public int narrowParameterTypeInInheritorArrayCastExample(VirtualInvokeInterface<byte[], Integer> callee, Integer param) {
        return callee.narrowParameterTypeInInheritorArrayCast(param);
    }

    public int narrowParameterTypeInInheritorObjectCastExample(VirtualInvokeInterface<byte[], Integer> callee, byte[] param) {
        return callee.narrowParameterTypeInInheritorObjectCast(param);
    }
}
  1. Run generation for narrowParameterTypeInInheritorArrayCastExample and narrowParameterTypeInInheritorObjectCastExample functions
  2. Open the generated tests

Expected behavior

At least, the engine should not fail. Probably, I expect to have two branches in each example.

Actual behavior

Failed requirements in castObject and castArray function.

Visual proofs (screenshots, logs, images)

image

Environment

There is no specific environment.

Additional context

An initial problem occurred on the following line of code: String.format("%02d", intNumber)

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions