Skip to content

Codegen: Remove unnecessary initial variables #25

@EgorkaKulikov

Description

@EgorkaKulikov

Currently some unused variables are generated for expected field values in tests. They are not involved in asserts later.
For example, generate tests for ArraysOverwriteValue.objectArray from our samples.

@Test @DisplayName("objectArray: a[0] == null : True -> return 2") public void testObjectArray_0OfAEqualsNull() throws Throwable { ArraysOverwriteValue arraysOverwriteValue = new ArraysOverwriteValue(); ObjectWithPrimitivesClass[] objectWithPrimitivesClassArray = new ObjectWithPrimitivesClass[1]; //NOTE: this field is unused, we should not generate it. ObjectWithPrimitivesClass initialObjectWithPrimitivesClassArray0 = objectWithPrimitivesClassArray[0]; int actual = arraysOverwriteValue.objectArray(objectWithPrimitivesClassArray); assertEquals(2, actual); ObjectWithPrimitivesClass finalObjectWithPrimitivesClassArray0 = objectWithPrimitivesClassArray[0]; assertNull(finalObjectWithPrimitivesClassArray0); }

We should avoid unused fields an corresponding warnings.

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-enhancementNew feature, improvement or change request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions