-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented workaround for eclipse bug displaying newline characters
- Loading branch information
Showing
5 changed files
with
75 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,25 @@ | ||
package org.quackery.junit; | ||
|
||
import static org.quackery.Suite.suite; | ||
|
||
import org.quackery.Case; | ||
import org.quackery.Suite; | ||
import org.quackery.Test; | ||
import org.quackery.run.Visitor; | ||
|
||
public class FixEmptySuiteBug { | ||
public static Test fixEmptySuiteBug(Test test) { | ||
return test instanceof Suite | ||
? fix((Suite) test) | ||
: test; | ||
} | ||
|
||
private static Test fix(Suite suite) { | ||
return suite.tests.isEmpty() | ||
? fixEmpty(suite) | ||
: fixChildren(suite); | ||
return new Visitor() { | ||
protected Test visit(Suite visiting) { | ||
Suite suite = (Suite) super.visit(visiting); | ||
return suite.tests.isEmpty() | ||
? successfulCase(suite.name) | ||
: suite; | ||
} | ||
}.visit(test); | ||
} | ||
|
||
private static Case fixEmpty(Suite suite) { | ||
return new Case(suite.name) { | ||
private static Case successfulCase(String name) { | ||
return new Case(name) { | ||
public void run() {} | ||
}; | ||
} | ||
|
||
private static Test fixChildren(Suite suite) { | ||
Suite fixedSuite = suite(suite.name); | ||
for (Test test : suite.tests) { | ||
fixedSuite = fixedSuite.add(fixEmptySuiteBug(test)); | ||
} | ||
return fixedSuite; | ||
} | ||
} |
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,33 @@ | ||
package org.quackery.junit; | ||
|
||
import static org.quackery.Suite.suite; | ||
|
||
import org.quackery.Case; | ||
import org.quackery.Suite; | ||
import org.quackery.Test; | ||
import org.quackery.run.Visitor; | ||
|
||
public class FixNewlineBug { | ||
public static Test fixNewlineBug(Test test) { | ||
return new Visitor() { | ||
protected Test visit(Suite visiting) { | ||
Suite suite = (Suite) super.visit(visiting); | ||
return suite(fix(suite.name)).addAll(suite.tests); | ||
} | ||
|
||
protected Test visit(final Case visiting) { | ||
return new Case(fix(visiting.name)) { | ||
public void run() throws Throwable { | ||
visiting.run(); | ||
} | ||
}; | ||
} | ||
}.visit(test); | ||
} | ||
|
||
private static String fix(String name) { | ||
return name | ||
.replace('\n', ' ') | ||
.replace('\r', ' '); | ||
} | ||
} |
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