Skip to content

Commit

Permalink
Refactor input resource setup in FieldTest
Browse files Browse the repository at this point in the history
This commit enhances readability by restructuring how the input resource 'Example' class is added in the 'testArrayLengthDeclaringTypeNested' method within FieldTest. The addition process is now within a single method call to 'addInputResource', improving code clarity and maintainability without altering functionality.
  • Loading branch information
SirYwell committed Aug 28, 2023
1 parent 7d40726 commit d1a327b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/test/java/spoon/test/field/FieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ void testArrayLengthModifiers() {
void testArrayLengthDeclaringTypeNested() {
// contract: the declaring type of a "length" access on arrays is set even when nested
Launcher launcher = new Launcher();
launcher.addInputResource(new VirtualFile("public class Example {\n" +
" public String[] array = new String[4];\n" +
" public static void main(String[] args) {\n" +
" Example other = new Example();\n" +
" int i = other.array.length;\n" +
" }\n" +
"}"));
launcher.addInputResource(new VirtualFile(
"public class Example {\n" +
" public String[] array = new String[4];\n" +
" public static void main(String[] args) {\n" +
" Example other = new Example();\n" +
" int i = other.array.length;\n" +
" }\n" +
"}"
));

CtModel ctModel = launcher.buildModel();
List<CtFieldReference<?>> elements = ctModel.getElements(new TypeFilter<>(CtFieldReference.class));
Expand Down

0 comments on commit d1a327b

Please sign in to comment.