Skip to content

Improve deepEquals on complicated models #1717

Open
@EgorkaKulikov

Description

@EgorkaKulikov

Description

DeepEquals still has some duplicated assertions. We need to investigate how to avoid them

To Reproduce

Run ContestEstimator with the following settings:

methodFilter = "com.google.common.collect.Queues.synchronizedDeque"
projectFilter = listOf("guava-26.0")

The following test is generated:

@Test
    public void testSynchronizedDeque() throws Exception  {
        ArrayDeque arrayDeque = new ArrayDeque();
        Object object = new Object();
        arrayDeque.add(object);
        
        Object actual = Queues.synchronizedDeque(arrayDeque);
        
        Object expected = createInstance("com.google.common.collect.Synchronized$SynchronizedDeque");
        setField(expected, "com.google.common.collect.Synchronized$SynchronizedObject", "delegate", arrayDeque);
        setField(expected, "com.google.common.collect.Synchronized$SynchronizedObject", "mutex", expected);
        Object expectedDelegate = getFieldValue(expected, "com.google.common.collect.Synchronized$SynchronizedObject", "delegate");
        Object actualDelegate = getFieldValue(actual, "com.google.common.collect.Synchronized$SynchronizedObject", "delegate");
        assertTrue(deepEquals(expectedDelegate, actualDelegate));
        
        Object expectedMutex = getFieldValue(expected, "com.google.common.collect.Synchronized$SynchronizedObject", "mutex");
        Object actualMutex = getFieldValue(actual, "com.google.common.collect.Synchronized$SynchronizedObject", "mutex");
        assertTrue(deepEquals(expectedMutex, actualMutex));
        assertTrue(deepEquals(expectedMutex, actualMutex));
        
    }

Last two assertions are incorrect.

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorcomp-contest-estimatorIssue is related to contest estimatorctg-bugIssue is a buglang-javaIssue is related to Java support

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions