-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reproduce bugs related to equo formatters (#1660)
- Loading branch information
Showing
11 changed files
with
214 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...c/test/java/com/diffplug/spotless/extra/groovy/GrEclipseFormatterStepSpecialCaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2023 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless.extra.groovy; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.diffplug.spotless.StepHarness; | ||
import com.diffplug.spotless.TestProvisioner; | ||
|
||
public class GrEclipseFormatterStepSpecialCaseTest { | ||
/** | ||
* https://github.com/diffplug/spotless/issues/1657 | ||
* | ||
* broken: ${parm == null ? "" : "<tag>$parm</tag>"} | ||
* works: ${parm == null ? "" : "<tag>parm</tag>"} | ||
*/ | ||
@Test | ||
public void issue_1657() { | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
StepHarness.forStep(GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral()).build()) | ||
.testResourceUnaffected("groovy/greclipse/format/SomeClass.test"); | ||
}); | ||
} | ||
|
||
@Test | ||
public void issue_1657_fixed() { | ||
StepHarness.forStep(GrEclipseFormatterStep.createBuilder(TestProvisioner.mavenCentral()).build()) | ||
.testResourceUnaffected("groovy/greclipse/format/SomeClass.fixed"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...rc/test/java/com/diffplug/spotless/extra/java/EclipseJdtFormatterStepSpecialCaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2016-2023 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless.extra.java; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.diffplug.spotless.StepHarness; | ||
import com.diffplug.spotless.TestProvisioner; | ||
|
||
public class EclipseJdtFormatterStepSpecialCaseTest { | ||
/** https://github.com/diffplug/spotless/issues/1638 */ | ||
@Test | ||
public void issue_1638() { | ||
StepHarness.forStep(EclipseJdtFormatterStep.createBuilder(TestProvisioner.mavenCentral()).build()) | ||
.testResource("java/eclipse/AbstractType.test", "java/eclipse/AbstractType.clean"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
testlib/src/main/resources/groovy/greclipse/format/SomeClass.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.somepackage | ||
|
||
class SomeClass { | ||
|
||
def func(parm) { | ||
"""<tag> | ||
${parm == null ? "" : "<tag>parm</tag>"} | ||
${parm == null ? "" : "<tag>parm</tag>"} | ||
</tag> | ||
""" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
testlib/src/main/resources/groovy/greclipse/format/SomeClass.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.somepackage | ||
|
||
class SomeClass { | ||
|
||
def func(parm) { | ||
"""<tag> | ||
${parm == null ? "" : "<tag>$parm</tag>"} | ||
${parm == null ? "" : "<tag>$parm</tag>"} | ||
</tag> | ||
""" | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
testlib/src/main/resources/java/eclipse/AbstractType.clean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package test; | ||
|
||
public abstract class AbstractType { | ||
|
||
private String _typeName; | ||
|
||
AbstractType(String typeName) { | ||
_typeName = typeName; | ||
} | ||
|
||
private String _type() { | ||
String name = getClass().getSimpleName(); | ||
return name.endsWith("Type") ? name.substring(0, getClass().getSimpleName().length() - 4) : name; | ||
} | ||
|
||
AbstractType argument() { | ||
throw new UnsupportedOperationException(getClass().getSimpleName()); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object another) { | ||
if (this == another) { | ||
return true; | ||
} | ||
return another instanceof AbstractType t && _typeName.equals(t._typeName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return _typeName.hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "(typeName)"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package test; | ||
|
||
|
||
|
||
|
||
public abstract class AbstractType { | ||
|
||
|
||
private String _typeName; | ||
|
||
AbstractType(String typeName) { | ||
_typeName = typeName; | ||
} | ||
|
||
|
||
|
||
private String _type() { | ||
String name = getClass().getSimpleName(); | ||
return name.endsWith("Type") | ||
? name.substring(0, getClass().getSimpleName().length() - 4) | ||
: name; | ||
} | ||
|
||
AbstractType argument() { | ||
throw new UnsupportedOperationException(getClass().getSimpleName()); | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(Object another) { | ||
if (this == another) { | ||
return true; | ||
} | ||
return another instanceof AbstractType t | ||
&& _typeName.equals(t._typeName); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public int hashCode() { | ||
return _typeName.hashCode(); | ||
} | ||
|
||
|
||
|
||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "(typeName)"; | ||
} | ||
|
||
|
||
} |