Skip to content

Commit

Permalink
Use the new error reporting to figure out exactly what was wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Apr 5, 2023
1 parent 4a9e269 commit a8d5db8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,30 @@
*/
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 */
/**
* 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.test");
.testResourceUnaffected("groovy/greclipse/format/SomeClass.fixed");
}
}
12 changes: 12 additions & 0 deletions testlib/src/main/resources/groovy/greclipse/format/SomeClass.fixed
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>
"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SomeClass {
"""<tag>
${parm == null ? "" : "<tag>$parm</tag>"}
${parm == null ? "" : "<tag>$parm</tag>"}
</tag>
</tag>
"""
}
}

0 comments on commit a8d5db8

Please sign in to comment.