Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Nov 30, 2021
1 parent ab1edee commit 496a4d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/spoon/test/prettyprinter/TestSniperPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,19 @@ void testSniperAddsSpaceAfterFinal() {
testSniper("sniperPrinter.SpaceAfterFinal", modifyField, assertContainsSpaceAfterFinal);
}

@Test
void testAbstractShouldBePrintedOnceAndWithProperSpacing() {
Consumer<CtType<?>> noOpModifyStaticClass = type -> {
CtType<?> staticClass = type.filterChildren(CtType.class::isInstance).first();
staticClass.descendantIterator().forEachRemaining(TestSniperPrinter::markElementForSniperPrinting);
};

BiConsumer<CtType<?>, String> assertDoesNotContainDiff = (type, result) ->
assertThat(result, not(containsString("abstractstatic abstract class AbstractFoo")));

testSniper("sniperPrinter.PrintAbstractOnceWithProperSpacing", noOpModifyStaticClass, assertDoesNotContainDiff);
}

/**
* 1) Runs spoon using sniper mode,
* 2) runs `typeChanger` to modify the code,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package sniperPrinter;

public class PrintAbstractOnceWithProperSpacing {
static abstract class AbstractFoo
{

}
}

0 comments on commit 496a4d1

Please sign in to comment.